1

I integrate google admob ads but it's displaying an error as,

W/Ads: There was a problem getting an ad response. ErrorCode: 0 08-09 16:05:43.933 24002-24002/com.locationtracking W/Ads: Failed to load ad: 0

I created a new ad id and copied the interstital ad unit id and app id but it's not working.

But when I used testing interstial id, it's displaying an ad. But when i copy and use the interstital id created, it's not displaying the ads. For past few days, I am struggling in this. I created new account and checked. Still same error.

MobileAds.initialize(this, "ca-app-pub-9172823052987868~3234462570");


    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-9172823052987868/8576265071");
    AdRequest adRequestInterstitial = new AdRequest.Builder().addTestDevice("deviceid").build();
    mInterstitialAd.loadAd(adRequestInterstitial);

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {

        }

        @Override
        public void onAdLoaded() {
            mAdIsLoading = false;
            showInterstitial();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            mAdIsLoading = false;
        }
    });
}

private void showInterstitial() {
    if (mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
        AdRequest adRequest = new AdRequest.Builder().addTestDevice("deviceid").build();
        mInterstitialAd.loadAd(adRequest);
    }
}


 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services-ads:9.2.1'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'

}
Shadow
  • 6,864
  • 6
  • 44
  • 93

2 Answers2

1

Common Error! There is no fault in your code. It's all good.

You just need to wait a little. Your ad id is newly created so it will take some time to fetch ads from google servers. You can verify this by adding banner/interstitial ad id you creating for earlier applications and you'll see that they work. So give it some time and it will work soon. At least for me, it happens all the time.

W/Ads: There was a problem getting an ad response. ErrorCode: 0 08-09 16:05:43.933 24002-24002/com.locationtracking W/Ads: Failed to load ad: 0

remove addTestDevice("deviceid"); from your code display real ads

AdRequest adRequestInterstitial = new AdRequest.Builder().addTestDevice("deviceid").build();

to

AdRequest adRequestInterstitial = new AdRequest.Builder().build();

try bellow code its running well:

public class MainActivity extends AppCompatActivity {

    InterstitialAd mInterstitialAd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       ////////////////////////// banner/////////////////////////
        AdView mAdView = (AdView) findViewById(R.id.adView);
        //AdRequest adRequest = new AdRequest.Builder().addTestDevice("7339C0A9091FA2D6AA9A2BF29077B5EA").build();
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
        ///////////////////////////////////////////////////////////

        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId(getResources().getString(R.string.interstitial_unit_id));
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {

                loadAdd();
            }
        });

        loadAdd();


    }


    @Override
    protected void onStart() {
        super.onStart();
        showInterstitial();
    }

    @Override
    protected void onStop() {
        super.onStop();
        showInterstitial();
    }


    //////////////////////////////////add Interstitial section//////////////////////////////////////////////

    private void showInterstitial() {
        // Show the ad if it's ready. Otherwise toast and restart the game.
        if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        } else {
            //Toast.makeText(this, "Ad did not load", Toast.LENGTH_SHORT).show();
            loadAdd();
        }
    }

    private void loadAdd() {
        // Request a new ad if one isn't already loaded, hide the button, and kick off the timer.
        if (!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) {
            //AdRequest adRequest = new AdRequest.Builder().addTestDevice("7339C0A9091FA2D6AA9A2BF29077B5EA").build();
            AdRequest adRequest = new AdRequest.Builder().build();
            mInterstitialAd.loadAd(adRequest);
        }
    }
   ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

compile 'com.google.android.gms:play-services-ads:8.3.0'

Neeraj Singh
  • 610
  • 9
  • 15
  • even if removed the addTestDevice, it's displaying as Received error HTTP response code: 403, There was a problem getting an ad response. ErrorCode: 0. – Shadow Aug 09 '17 at 11:51
0

You can not display real ad in the test device, so you should remove the test device code when you upload your apk=> change your code as this

 AdRequest adRequestInterstitial = new AdRequest.Builder().build();       
codecrazer
  • 525
  • 5
  • 20