AdMob ErrorCode 0 mostly

2019-07-26 19:50发布

问题:

I have a problem with my Android App which I'm trying to add ads for, the weird thing is that the ad loads perfectly on the first activity, but none of the others. I've followed the instructions on https://developers.google.com/admob/android/existing-app, but to no avail it still only works with the first activity. I have a different Ad Unit ID for each activity that I have ads on as well, and have copy-pasted them from the website to avoid mistakes, and have removed all whitespace.

The response I get is:

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

I've done research on why I'd get this response from AdMob, and I've tried the solutions I have found, they are to add the correct version (and check for updates) of the Google Play Services to my build.gradle file, to add the version to my manifest file, I am running it on the stock rom that came with a real phone (LG G4 running Lollipop) I even tried on a different phone which was also running stock Android to get the same result.

The way I load the ads onto my page is with this code:

AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

This is the same on every activity with ads on it.

This is a snippet of my Manifest file:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

Finally, this is the ad snippet of my layout file, which is also the same in all of my layouts:

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_home">
</com.google.android.gms.ads.AdView>

I have a string resource for each different activity Ad Unit ID.

回答1:

It just started working, I changed nothing. Maybe there was a problem building it before? Who knows, thanks for all the help though guys.



回答2:

 AdView adView = findViewById(R.id.adView); 
 AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
adView.loadAd(adRequest);  


回答3:

Whenever you load Admob banner ad this gives 0 error.This is just because you have not signed it.you must load and show Test admob Banner ad.if test ad is servering perfectly then you will get right ad in signed apk.0 error may be just because you have not signed apk



回答4:

did you added this line in your manifest file?

<activity
    android:name="com.google.android.gms.ads.AdActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

or try like this

Open your adMob account and create new sets of keys,and put this keys(banner/interstitial)in your project.this is happens to me once i fixed like this,try this solution. or still issues create new app (just change the name) in adMob and create new keys



标签: android admob