本文介绍了在 Unity 4.6 中构建游戏的实时 Android 设备上未显示有趣的广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Unity 版本 ==> 4.6.0
Admob 版本 ==> Google 移动广告 Unity 插件 v3.1.3

I am using Unity Version ==> 4.6.0
Admob Version ==> Google Mobile Ads Unity Plugin v3.1.3

我正在使用下面的代码来展示插页式广告.

I am using below code to show interstitial ads.

public const string adsIdAndroid = "ca-app-pub-3940256099942544/1033173712";
  public void RequestInterstitial()
    {
        try
        {
            if (!AdsFlag)
            {
                Debug.Log("Requested Interstitial");
               // Initialize an InterstitialAd.
                interstitial = new InterstitialAd(adsIdAndroid);
                // Create an empty ad request.
                AdRequest request = new AdRequest.Builder().Build();
                // Load the interstitial with the request.
                interstitial.LoadAd(request);
            }
        }
        catch (Exception ex) { }

    }

    public void ShowInterstitial()
    {
        try
        {
            //Debug.Log("Try Show InterstitialAd");
            if (!AdsFlag)
            {
                if (interstitial.IsLoaded())
                {
                    Debug.Log("Show InterstitialAd");
                    interstitial.Show();
                    AdsFlag = true;
                }
                else
                {
                    Debug.Log("InterstitialAd Not Loaded");
                    RequestInterstitial();
                }
            }
        }
        catch (Exception ex) { }
    }

我正在调用上面的函数如下:

I am calling above function as below :

    void Start()
        {
            AdsFlag = false;
            RequestInterstitial();
    }
 void Update()
    {
        ShowInterstitial();

}

Unity 日志如下:

Unity Log As Below :

Requested Interstitial
UnityEngine.Debug:Log(Object)
Dummy CreateInterstitialAd
UnityEngine.Debug:Log(Object)
Dummy LoadAd
UnityEngine.Debug:Log(Object)
Dummy IsLoaded
UnityEngine.Debug:Log(Object)
Show InterstitialAd
UnityEngine.Debug:Log(Object)
Dummy ShowInterstitial
UnityEngine.Debug:Log(Object)

但在真正的 Android 设备上,广告不显示..
如何解决这个问题?

But on Real Android Device , ads not showing up..
How to solve this problem ?

推荐答案

我们中的许多人都面临着与 unity 和 admob 类似的问题

Many of us facing similar problem with unity and admob

我刚刚通过以下步骤解决了这个问题:

I just solved this problem by following below steps:

1) 我删除了 AssetsPluginsAndroid 下的 google-play-services_lib 文件夹2) 然后选择 Menu Assets -> Play Service Resolver -> Android Resolver -> Resolve Client Jars.

1) I have deleted google-play-services_lib folder at AssetsPluginsAndroid2) Then Select Menu Assets -> Play Service Resolver -> Android Resolver -> Resolve Client Jars.

我只是按照这 2 个步骤操作,现在我的谷歌广告工作正常.也许这个答案可以帮助您找出问题.

I just followed this 2 steps and now my google ads working fine.Maybe this answer help you to figure out problem.

这篇关于在 Unity 4.6 中构建游戏的实时 Android 设备上未显示有趣的广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-17 17:13