1

Test ads (with test ad id) are loading but the real ads are failed to load with error code id 1.

I checked that ad unit id is also right.

Every time its going to onAdFailedToLoad with value of i as 1

Please check the code

mInterstitialAd = new InterstitialAd(this);
        /*mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
        mInterstitialAd.loadAd(new AdRequest.Builder().build());*/
        mInterstitialAd.setAdUnitId(String.valueOf(R.string.admob_interstitial_ad_id));
        mInterstitialAd.loadAd(new AdRequest.Builder().build());
        //.addTestDevice("25E662D1EDF4290XXXXXXXXXXXX")
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdFailedToLoad(int i) {
                super.onAdFailedToLoad(i);
                Log.e("TAG", "ADMOB INTERSTITIAL AD - " + i);
            }

            public void onAdLoaded() {
                if (mInterstitialAd.isLoaded()) {
                    mInterstitialAd.show();
                } else {
                    Log.d("TAG", "The interstitial wasn't loaded yet.");
                }
            }
        });
akkk
  • 1,457
  • 4
  • 23
  • 41
  • it will take some time for ads to appear if you use real ids, if it's working with test ids. It means you have set it up correctly. – Amir Dora. Jul 14 '18 at 11:07
  • Possible duplicate of [AdMob real ads are not showing, only test ads are displayed](https://stackoverflow.com/questions/43374698/admob-real-ads-are-not-showing-only-test-ads-are-displayed) – Amir Dora. Jul 14 '18 at 11:09

1 Answers1

0

Test ads might be loading because the adUnitId is ignored but for production, your adUnitId doesn't appear to be correct. Look at this:

mInterstitialAd.setAdUnitId(String.valueOf(R.string.admob_interstitial_ad_id));

R.string.admob_interstitial_ad_id is an Integer that gets converted to string, but that's probably not what you are looking for. Try to get ad id as follows:

mInterstitialAd.setAdUnitId(getString(R.string.admob_interstitial_ad_id));
vanomart
  • 1,739
  • 1
  • 18
  • 39