Google Banner ads Failed to load ad: 0

2019-07-20 07:52发布

问题:

I am unable to load Google banner ad in my activity. I have added all the permissions and tags described in developer.google.com and also have refereed others questions in StackOverflow.

AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("477359CAFFxxxxxxxxxxxxxxxxxxx").build();
 enter code hereadView.loadAd(adRequest);{}

"My logcat output: and i have added all permissions and meta tags"

04-12 10:07:18.753: W/ResourcesManager(17370): Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
        04-12 10:07:18.753: W/ResourcesManager(17370): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
        04-12 10:07:18.846: I/WebViewFactory(17370): Loading com.google.android.webview version 40 (1832189-arm) (code 424501)
        04-12 10:07:18.869: I/LibraryLoader(17370): Time to load native libraries: 3 ms (timestamps 5621-5624)
        04-12 10:07:18.869: I/LibraryLoader(17370): Expected native library version number "",actual native library version number ""
        04-12 10:07:18.875: V/WebViewChromiumFactoryProvider(17370): Binding Chromium to main looper Looper (main, tid 1) {28944cc5}
        04-12 10:07:18.876: I/LibraryLoader(17370): Expected native library version number "",actual native library version number ""
        04-12 10:07:18.876: I/chromium(17370): [INFO:library_loader_hooks.cc(108)] Chromium logging enabled: level = 0, default verbosity = 0
        04-12 10:07:18.883: I/BrowserStartupController(17370): Initializing chromium process, singleProcess=true
        04-12 10:07:18.884: W/art(17370): Attempt to remove local handle scope entry from IRT, ignoring
        04-12 10:07:18.892: W/chromium(17370): [WARNING:resource_bundle.cc(304)] locale_file_path.empty()
        04-12 10:07:18.892: W/AudioManagerAndroid(17370): Requires BLUETOOTH permission
        04-12 10:07:18.893: I/chromium(17370): [INFO:aw_browser_main_parts.cc(63)] Load from apk succesful, fd=36 off=49196 len=3229
        04-12 10:07:18.894: I/chromium(17370): [INFO:aw_browser_main_parts.cc(76)] Loading webviewchromium.pak from, fd:37 off:390788 len:1143511
        04-12 10:07:18.899: I/Adreno-EGL(17370): <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
        04-12 10:07:18.951: I/Ads(17370): Starting ad request.
        04-12 10:07:18.952: I/Ads(17370): Use AdRequest.Builder.addTestDevice("F9D483C5C3943E9EFDC31D1B4C183CF8") to get test ads on this device.
        04-12 10:07:18.961: D/OpenGLRenderer(17370): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
        04-12 10:07:18.967: D/Atlas(17370): Validating map...
        04-12 10:07:19.000: I/OpenGLRenderer(17370): Initialized EGL, version 1.4
        04-12 10:07:19.003: D/OpenGLRenderer(17370): Enabling debug mode 0
        04-12 10:07:19.050: I/Ads(17370): CsiReporterFactory: CSI is not enabled. No CSI reporter created.
        04-12 10:07:21.086: W/Ads(17370): There was a problem getting an ad response. ErrorCode: 0
        04-12 10:07:21.110: W/chromium(17370): [WARNING:data_reduction_proxy_settings.cc(328)] SPDY proxy OFF at startup
        04-12 10:07:21.120: W/art(17370): Attempt to remove local handle scope entry from IRT, ignoring
        04-12 10:07:21.124: W/AwContents(17370): onDetachedFromWindow called when already detached. Ignoring`enter code here`
        04-12 10:07:21.140: W/Ads(17370): Failed to load ad: 0

回答1:

I had to same problem. I was informed on my admob account that no ads were loaded yet because I had not created a payment account. Ensure you have created a payment account on your admob page.



回答2:

Use this code recommended by google developer site for testing banner ad

 AdView mAdView = (AdView) findViewById(R.id.adView);
 AdRequest request = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4")  // My Galaxy Nexus test phone
            .build();
 mAdView.loadAd(request);

Here is the full nice documentation how to do this in android studio click here

You may solved your problem already, but it may help someone else. My suggestions are :

  1. Restart emulator
  2. if not work go through the upper link and repeat every steps given there and enjoy


回答3:

Change your code as below:

     AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice("F9D483C5C3943E9EFDC31D1B4C183CF8")
            .build();
    adView.loadAd(adRequest);

Ensure you have imported google play services library and added the correct ads:adUnitId in the layout file.



回答4:

Uninstalled the google play service update and the ads are working.



标签: android admob