Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdMob RewardedVideoAd.loadAd always returns "failed to load ads, error code: 0"

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:

AdMob page

like image 225
Kimi Chiu Avatar asked Jul 04 '16 09:07

Kimi Chiu


2 Answers

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.

like image 85
Kimi Chiu Avatar answered Oct 05 '22 21:10

Kimi Chiu


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

like image 41
PSN Avatar answered Oct 05 '22 21:10

PSN