I'm using firebase-ads:9.2.0 with API level 24.
And unity-ads aar module is imported by adding compile(name:'unity-ads', ext:'aar') to my build.gradle.
Everything goes fine if I choose to use UnityAds API directly.
But when I try to integrate unity-ads with AdMob like this:
mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance( this );
mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
@Override
public void onRewardedVideoAdLoaded() {
logger.debug("onRewardedVideoAdLoaded");
}
@Override
public void onRewardedVideoAdOpened() {
logger.debug("onRewardedVideoAdOpened");
}
@Override
public void onRewardedVideoStarted() {
logger.debug("onRewardedVideoStarted");
}
@Override
public void onRewardedVideoAdClosed() {
logger.debug("onRewardedVideoAdClosed");
}
@Override
public void onRewarded(RewardItem rewardItem) {
logger.debug("onRewarded");
}
@Override
public void onRewardedVideoAdLeftApplication() {
logger.debug("onRewardedVideoAdLeftApplication");
}
@Override
public void onRewardedVideoAdFailedToLoad(int i) {
Toast.makeText(
getApplicationContext(),
"onRewardedVideoAdFailedToLoad",
Toast.LENGTH_SHORT ).show();
}
});
AdRequest adRewardRequest = new AdRequest.Builder()
.addTestDevice("E921B48960E16DA3ABD13C4AFB7052A4")
.build();
mRewardedVideoAd.loadAd(
getResources().getString(R.string.reward_ad_unit_id),
adRewardRequest );
It always returns
There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0.
Is there anything I did it in the wrong way?
Or I just missed some steps?
Here is my AdMob page screenshot:
Okay, I found solutions.
The first thing is that I didn't include adapters in my project.
I have to download the adpaters here: Third-party network adapters
And put it into the libs folder. These adapters are not included in the SDKs(if you download it from github).
Second, I have to remove this line out of my code.
.addTestDevice("E921B48960E16DA3ABD13C4AFB7052A4")
It seems like if the AdMob treat this device as a test device, there will be no any video ad to be downloaded(at least in my case).
Same thing happens if I choose to use the AVD, they force to show test ads on these emulators.
So I change to Genymotion, remove the addTestDevice() and then it works.
Usually this happens for newly created ads, so wait for an hour and try again.
public static final int ERROR_CODE_INTERNAL_ERROR
Something happened internally; for instance, an invalid response was received from the ad server.
Constant Value: 0
Source: Google Developers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With