在 Unity 4.6 中构建游戏的实时 Android 设备上未显示插页式广告
Interestial Ads Not Showing on Live Android Device for Game Build in Unity 4.6
我使用的是 Unity 版本 ==> 4.6.0
Admob 版本 ==> Google Mobile Ads Unity Plugin v3.1.3
我正在使用以下代码展示插页式广告。
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) { }
}
我调用上面的函数如下:
void Start()
{
AdsFlag = false;
RequestInterstitial();
}
void Update()
{
ShowInterstitial();
}
Unity 日志如下:
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 设备上,广告未显示..
如何解决这个问题?
我们中的许多人都面临着与 unity 和 admob 类似的问题
我刚刚通过以下步骤解决了这个问题:
1) 我已删除 google-play-services_lib 文件夹 Assets\Plugins\Android
2) 然后 Select 菜单资产 -> 播放服务解析器 -> Android 解析器 -> 解析客户端 Jars。
我只执行了这 2 个步骤,现在我的 google 广告效果很好。
也许这个答案可以帮助您解决问题。
我使用的是 Unity 版本 ==> 4.6.0
Admob 版本 ==> Google Mobile Ads Unity Plugin v3.1.3
我正在使用以下代码展示插页式广告。
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) { }
}
我调用上面的函数如下:
void Start()
{
AdsFlag = false;
RequestInterstitial();
}
void Update()
{
ShowInterstitial();
}
Unity 日志如下:
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 设备上,广告未显示..
如何解决这个问题?
我们中的许多人都面临着与 unity 和 admob 类似的问题
我刚刚通过以下步骤解决了这个问题:
1) 我已删除 google-play-services_lib 文件夹 Assets\Plugins\Android 2) 然后 Select 菜单资产 -> 播放服务解析器 -> Android 解析器 -> 解析客户端 Jars。
我只执行了这 2 个步骤,现在我的 google 广告效果很好。 也许这个答案可以帮助您解决问题。