-1

When I try implementing admit to android application am running into this error.If I insert test device hash I only see admob testing ads only. When I comment out test for production this is the error I get on the Error log

W/Ads: There was a problem getting an ad response. ErrorCode: 0
W/Ads: Failed to load ad: 0

Here is my code code for implementing the advert

public void showAds() {
    String deviceId = MGUtilities.getDeviceID(getApplicationContext());
    Log.e("DEVICE ID", "------------------------------------------");
    Log.e("DEVICE ID", deviceId);
    Log.e("DEVICE ID", "------------------------------------------");
    FrameLayout frameAds = (FrameLayout) findViewById(R.id.frameAds);
    if (Config.WILL_SHOW_ADS) {
        frameAds.setVisibility(View.VISIBLE);
        if (adView == null) {
            adView = new AdView(this);
            adView.setAdSize(AdSize.SMART_BANNER);
            adView.setAdUnitId(Config.BANNER_UNIT_ID);
            frameAds.addView(adView);

            AdRequest.Builder builder = new AdRequest.Builder();
            if (Config.TEST_ADS_USING_TESTING_DEVICE)
                builder.addTestDevice(Config.TESTING_DEVICE_HASH);

            if(Config.TEST_ADS_USING_EMULATOR)
                builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);

            AdRequest adRequest = builder.build();
            // Start loading the ad in the background.
            adView.loadAd(adRequest);
        }
    } else {
        frameAds.setVisibility(View.GONE);
    }
}

What might be wrong? Thanks.

G B
  • 2,323
  • 3
  • 18
  • 32
  • Please explain your problem briefly, you can post here its relevant code too. So, I better understand – Ramesh sambu Dec 20 '17 at 17:00
  • [It's old](https://stackoverflow.com/q/18591724/3290339) but might be helpful. – Onik Dec 20 '17 at 17:03
  • check out this post: - https://stackoverflow.com/questions/31972862/admob-getting-an-ad-response-errorcode-0-failed-to-load-ad0 – gautam Dec 21 '17 at 19:53

2 Answers2

0

Your code is fine you have to wait for sometime after generating ad id because usually admob need time to show live ads to you. If you are now able to see ads after maximum 24 hours then please contact admob customer care for help.

0

If you are using live Admob ads id in Debug mode, it will show this error.

For live Admob ids to load create a Release apk and try to check in that.

Abubakker Moallim
  • 1,610
  • 10
  • 20