Reputation: 791
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.
Upvotes: 77
Views: 75200
Reputation: 1111
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!
Upvotes: 0
Reputation: 679
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.
Upvotes: 3
Reputation: 460
Solution:
How to setup payment methods in AdMob:
If you are still experiencing problems, feel free to contact me via email: [email protected]
Upvotes: 17
Reputation: 14636
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
Upvotes: 0
Reputation: 3454
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
Upvotes: 2
Reputation: 258
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.
Upvotes: 0
Reputation: 149
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.
Upvotes: 15
Reputation: 2286
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.
Upvotes: 0
Reputation: 1899
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" />
Upvotes: 4
Reputation: 67
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();
Upvotes: 3
Reputation: 488
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
Upvotes: 17
Reputation: 1
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.
Upvotes: 0
Reputation: 3645
Make sure you don't have an add blocker installed on your device.
Upvotes: 4
Reputation: 9614
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
Upvotes: 3
Reputation: 2208
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
Upvotes: 84
Reputation: 139
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"
Upvotes: 7
Reputation: 51
If your ad unit id string is like this: xyz You should remove the translatable part. For me it fixed the problem.
Upvotes: 0
Reputation: 1843
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
Upvotes: 4
Reputation: 791
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 ..
Upvotes: 2
Reputation: 1177
try changing ads:adSize="BANNER"
with ads:adSize="SMART_BANNER"
Upvotes: 2