- Home /
AdMob rewarded Ad fails to load after several success ad shows
Hi, I implemented AdMob ads into my Android Unity Game that im working on(Unity v.2020.1.0f1).
In my game Player can get resurrected by watching the rewarded ad. Player request ad, ad is shown correctly and player gets reward (gets resurrected).
This loop works several times and suddenly ads fail to load, and the only message I get from EventArgs is Internal error
The interesting thing is, even if Player chooses another level, which makes Unity to load new Scene, the rewarded ads still fails to load. The only thing that makes rewarded ads work again is shutting the game down completely and turning it on. Then again they work several times. I can easly display like 5 or 8 ads before it fails to load with Internal Error.
I also have Intersitial Ads which works all the time, even if Rewarded ad fails to load.
Here is my RewardedAdsController which handles all the ads logic:
using UnityEngine;
using GoogleMobileAds.Api;
using System;
using Character;
namespace Background.Script
{
public class RewardedAdController : MonoBehaviour
{
static readonly string AndroidTestAdId = "ca-app-pub-3940256099942544/5224354917";
static readonly string IOSTestAdId = "ca-app-pub-3940256099942544/1712485313";
public string androidAdId;
public string iOsAdId;
public AdHandlerAbstract rewardAdHandler;
private RewardedAd _rewardedAd;
public const int UNKOWN = 0;
public const int ANDROID = 1;
public const int IOS = 2;
private int _deviceType = 0;
private int amountOfRetryLoad = 0;
void Start()
{
#if UNITY_ANDROID
_deviceType = 1;
#elif UNITY_IPHONE
_deviceType = 2;
#endif
CreateAndLoadRewardedAd();
}
public string ProvideAdId()
{
switch (_deviceType)
{
case ANDROID:
if (DataManager.instance.useTestAds)
{
return AndroidTestAdId;
}
else
{
return androidAdId;
};
case IOS:
if (DataManager.instance.useTestAds)
{
return IOSTestAdId;
}
else
{
return iOsAdId;
};
}
return "unexpected_platform";
}
public void CreateAndLoadRewardedAd()
{
_rewardedAd = new RewardedAd(ProvideAdId());
// Called when an ad request has successfully loaded.
_rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
// Called when an ad request failed to load.
_rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
// Called when an ad is shown.
_rewardedAd.OnAdOpening += HandleRewardedAdOpening;
// Called when an ad request failed to show.
_rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
// Called when the user should be rewarded for interacting with the ad.
_rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
// Called when the ad is closed.
_rewardedAd.OnAdClosed += HandleRewardedAdClosed;
// Load the rewarded ad with the request.
_rewardedAd.LoadAd(CreateAdRequest());
}
public void HandleRewardedAdLoaded(object sender, EventArgs args)
{
//Invoked when an ad has finished loading.
Debug.Log("Add LOADED");
rewardAdHandler.AdLoaded();
}
public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args)
{
//Invoked when an ad fails to load.
//The Message property of the provided AdErrorEventArgs describes the type of failure that occurred.
//rewardAdHandler.AdFailedToLoad();
Debug.Log("Add Failed To Load");
Debug.Log("-------------------");
Debug.Log("MESSAGE: " + args.Message);
Debug.Log("TYPE: " + args.GetType());
Debug.Log("HASH CODE: " + args.GetHashCode());
Debug.Log("TO STRING: " + args.ToString());
Debug.Log("SENDER - TO STRING: " + sender.ToString());
Debug.Log("-------------------");
_rewardedAd = null;
Invoke("ReloadFailedAd", 10f);
}
private void ReloadFailedAd()
{
if (amountOfRetryLoad < 3)
{
amountOfRetryLoad++;
CreateAndLoadRewardedAd();
}
}
public void HandleRewardedAdOpening(object sender, EventArgs args)
{
//Invoked when the ad is displayed, covering the device's screen.
//This is a good place to pause your app audio output or game loop, if necessary.
rewardAdHandler.AdOpening();
}
public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
{
//Invoked when an ad fails to display.
//The Message property of the provided AdErrorEventArgs describes the type of failure that occurred.
Debug.Log("Add Failed To Show");
Debug.Log("-------------------");
Debug.Log("MESSAGE: " + args.Message);
Debug.Log("TYPE: " + args.GetType());
Debug.Log("HASH CODE: " + args.GetHashCode());
Debug.Log("TO STRING: " + args.ToString());
Debug.Log("SENDER - TO STRING: " + sender.ToString());
Debug.Log("-------------------");
_rewardedAd = null;
Invoke("ReloadFailedAd", 10f);
}
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
//Invoked when the rewarded video ad is closed due to the user tapping on the close icon or using the back button.
//If your app paused its audio output or game loop, this is a great place to resume it.
CreateAndLoadRewardedAd(); //Insantly loading another ad
rewardAdHandler.AdClosed();
}
public void HandleUserEarnedReward(object sender, Reward args)
{
//Invoked when a user should be rewarded for watching a video.
//The Reward parameter describes the reward to be presented to the user.
rewardAdHandler.ApplyReward();
}
public void RequestAdShow()
{
if (IsAdLoaded())
{
_rewardedAd.Show();
}
else
{
rewardAdHandler.AdClosed();
}
}
public bool IsAdLoaded()
{
return _rewardedAd != null && _rewardedAd.IsLoaded();
}
private AdRequest CreateAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice("371179F5BA12E419C925A5F38CCFC43")
.Build();
}
}
}
And here is logcat debug from HandleRewardedAdFailedToLoad:
08-27 19:20:53.995 25441 27536 I Unity : Add Failed To Load
08-27 19:20:53.995 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:53.995 25441 27536 I Unity :
08-27 19:20:53.996 25441 27536 I Unity : -------------------
08-27 19:20:53.996 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:53.996 25441 27536 I Unity :
08-27 19:20:53.996 25441 27536 I Unity : MESSAGE: Internal error
08-27 19:20:53.996 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:53.996 25441 27536 I Unity :
08-27 19:20:53.996 25441 27536 I Unity : TYPE: GoogleMobileAds.Api.AdErrorEventArgs
08-27 19:20:53.996 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:53.996 25441 27536 I Unity :
08-27 19:20:53.999 25441 27536 I Unity : HASH CODE: 1213449600
08-27 19:20:53.999 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:53.999 25441 27536 I Unity :
08-27 19:20:54.000 25441 27536 I Unity : TO STRING: GoogleMobileAds.Api.AdErrorEventArgs
08-27 19:20:54.000 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:54.000 25441 27536 I Unity :
08-27 19:20:54.000 25441 27536 I Unity : SENDER - TO STRING: GoogleMobileAds.Api.RewardedAd
08-27 19:20:54.000 25441 27536 I Unity : (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
08-27 19:20:54.000 25441 27536 I Unity :
08-27 19:20:54.000 25441 27536 I Unity : -------------------
Im using the AdMob test ads, but i tested it with real ads too and the problem still exists.
Please help, what can be the problem?
Your answer
![](https://koobas.hobune.stream/wayback/20220613010644im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to implement Admob Native Ads on a ScrollRect in Unity 2 Answers
How to make a No Ads Button 0 Answers
App crash on launch. 1 Answer
admob interstitial not showing correctly 0 Answers