admob getting an ad response. ErrorCode: 0 Failed to load ad:0
AndroidAdmobAndroid Problem Overview
I have followed many answers about that error here, but my problem is not solved. Every time I run my app no ads appear and I get this error message in Logcat:
>"There was a problem getting an ad response. ErrorCode: 0 Failed to load ad:0"
Here is my java code. What did I miss?
private void LoadAds() {
AdView mAdView = (AdView) findViewById(R.id.linearLayoutAdmob);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
and here my xml layout with admob at the last lines
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background_play"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/rlayout1"
android:layout_width="fill_parent"
android:layout_height="0px"
android:padding="5dip"
android:layout_weight="2.3" >
<com.aapps.find.TouchImage
android:id="@+id/gameimage1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/hitimage1"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/hit"
android:visibility="invisible" />
<ImageView
android:id="@+id/errorimage1"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/miss1"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlayoutprogress"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="0.1" >
<com.aapps.find.utility.SaundProgressBar
android:id="@+id/progressBar"
style="@style/Widget.ProgressBar.RegularProgressBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlayout2"
android:padding="5dip"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="2.3" >
<com.aapps.find.TouchImage
android:id="@+id/gameimage2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<ImageView
android:id="@+id/hitimage2"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/hit"
android:visibility="invisible" />
<ImageView
android:id="@+id/errorimage2"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/miss1"
android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlstatus"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="0.3" >
<TextView
android:id="@+id/scoreCount"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="15dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#fffd7a"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"/>
<TextView
android:id="@+id/hitCount"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="#fffd7a"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@id/scoreCount"/>
<ImageView
android:id="@+id/imgSound"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:src="@drawable/sound" />
<ImageView
android:id="@+id/imgHint"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="15dp"
android:layout_toLeftOf="@id/imgSound"
android:src="@drawable/hint" />
<TextView
android:id="@+id/hintCount"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="26dp"
android:textSize="16sp"
android:textStyle="bold"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_toLeftOf="@id/imgSound"/>
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/linearLayoutAdmob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/admob_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
I cannot figure what the problem is. I'm new in android development.
Android Solutions
Solution 1 - Android
This is what google says
> "It could be that you have only recently created a new Ad Unit ID and > requesting for live ads. It could take a few hours for ads to start > getting served if that is that case. If you are receiving test ads > then your implementation is fine. Just wait a few hours and see if you > are able to receive live ads then. If not, can send us your Ad Unit ID > for us to look into."
so basically you have to wait for a few hours :)
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo
Solution 2 - Android
If you are using live admob ads id in development mode application , it will show this error.
Use debug mode admob ads id during development and live admob ids in release mode app
Solution 3 - Android
Solution:
- If your account is new, that might be the problem. Wait 2-3 hours, after that it will automatically start showing ads.
- If it still doesn't show ads, maybe you forgot to setup a payment method.
How to setup payment methods in AdMob:
- Login into AdMob
- Navigate to "Payments" tab on the left side of your screen
- Type in your real address, name and account type
- Put the ads (ad unit) into the application
- Wait for 2-3 Hours
- There you go!
If you are still experiencing problems, feel free to contact me via email: [email protected]
Solution 4 - Android
If you have just opened your admob account, Fill the payment details first, else you will not get the ad impression even in the test mode.
Solution 5 - Android
You have to verify the size of the ad you created, if it is smaller it will always get this error. Just verify and change to the specific size:
ads:adSize="360x100"
Solution 6 - Android
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
Solution 7 - Android
Make sure you don't have an add blocker installed on your device.
Solution 8 - Android
Make sure you've added this in the AndroidManifest.xml file
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Solution 9 - Android
I was getting this error because admob has blocked my app to serve ads. So I changed the package name and everything started to work perfectly fine
Solution 10 - Android
I added the code below for the testing environment
AdRequest adRequest = new AdRequest.Builder().addTestDevice(your device id)
//When you testing on emulator
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
Solution 11 - Android
May not apply to all, but my personal problem was turning off my Pi-hole
And yes for those wondering, I like to regularly shoot myself in the foot.
Solution 12 - Android
try changing ads:adSize="BANNER"
with ads:adSize="SMART_BANNER"
Solution 13 - Android
i found the error from the emulator after i install the app on real device the ads shown perfectly thanks everyone and i hope my answer being useful for others ..
Solution 14 - Android
One more reason can be: Missing payment information
Your ad units aren't serving ads because your payment information is missing. Add your payment information now. Learn More
Solution 15 - Android
If your ad unit id string is like this:
Solution 16 - Android
Most likely you have recently created a new Ad Unit ID, but you also could get this error because you're passing a wrong Ad Unit ID.
Solution 17 - Android
Make sure your ads not violate Google Ads rule, otherwise you have to fill appeal form first to contact AdMob support and after they re-enable your ads serving, ads should appear.
Solution 18 - Android
Dear Friend if after then you start to using your real ADMOB app ID instead of testing ids , just wait a few hours(for me it takes about 2-3 hours) after which you will get live admob ads.
Solution 19 - Android
If you have just implemented ads and want to test it only and still not getting ads seen then use this test ads ids Sample Ads Ids
One more thing, if you are testing it in emulator then use this in Kotlin
val adRequest = AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build()
Also go through this
Solution 20 - Android
In my case, It worked on switching to another internet connection. Earlier I was using my company's wifi and changing the connection to my personal wifi hotspot it worked!