54

I am trying to load Admob Native ads. Previously (before app was updated) ads used to show but now they are not showing. I have posted the code, xml and the Logcat below.

Code

NativeExpressAdView adView = (NativeExpressAdView) myView.findViewById(R.id.adView);

    AdRequest request = new AdRequest.Builder()
            .addTestDevice("5BCFF0AAE83AF424648A954038C71DE6")
            .addTestDevice("A5E3E2068BD88202CBC281AD76984BEE")//infocus
            .build();

    adView.loadAd(request);

XML

<com.google.android.gms.ads.NativeExpressAdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            ads:adSize="320x150"
            ads:adUnitId="ca-app-pub-5059726881726792/6223900262"></com.google.android.gms.ads.NativeExpressAdView>

Logcat

07-14 20:39:57.349 11508-11508/? W/Ads: Failed to load ad: 0
07-14 20:40:07.373 11508-11663/? W/Ads: There was a problem getting an ad response. ErrorCode: 0

Fail to forward ad response.
                                  android.os.DeadObjectException
                                      at android.os.BinderProxy.transactNative(Native Method)
                                      at android.os.BinderProxy.transact(Binder.java:511)
                                      at com.google.android.gms.ads.internal.request.ab.a(:com.google.android.gms:93)
                                      at com.google.android.gms.ads.internal.request.service.i.run(:com.google.android.gms:638)
                                      at com.google.android.gms.ads.internal.util.u.call(:com.google.android.gms:1055)
                                      at com.google.android.gms.ads.internal.util.v.run(:com.google.android.gms:75)
                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                      at java.lang.Thread.run(Thread.java:818)

07-14 20:40:19.539 1975-4922/? W/Ads: Fail to forward ad response.
                                  android.os.DeadObjectException
                                      at android.os.BinderProxy.transactNative(Native Method)
                                      at android.os.BinderProxy.transact(Binder.java:511)
                                      at com.google.android.gms.ads.internal.request.ab.a(:com.google.android.gms:93)
                                      at com.google.android.gms.ads.internal.request.service.i.run(:com.google.android.gms:638)
                                      at com.google.android.gms.ads.internal.util.u.call(:com.google.android.gms:1055)
                                      at com.google.android.gms.ads.internal.util.v.run(:com.google.android.gms:75)
                                      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
                                      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                      at java.lang.Thread.run(Thread.java:818)
akkk
  • 1,457
  • 4
  • 23
  • 41

17 Answers17

77

There is no fault in your code. It's all good. You just need to wait a little. Your ad id is newly created so it will take some time to fetch ads from google servers. You can verify this by adding banner/interstitial ad id you creating for earlier applications and you'll see that they work. So give it some time and it will work soon. At least for me, it happens all the time. Can't surely say for you but why not give it a try?

user3314639
  • 786
  • 7
  • 7
  • 18
    "Wait a little" == ~1hour in my case. – t0m Jun 13 '17 at 08:53
  • 4
    I dont know why but I wait over 2 days. It's still error. I try to create another apps with another admob account. It runs well. I want to use my primary account. any idea ? – Mr Special Jun 07 '19 at 03:34
  • @MrSpecial did you solved this problem? if so, how? – pinkcat May 23 '20 at 07:08
  • @pinkcat yep, it remember it take a long time to have official email from google which inform that my admob account is activated. Then I use admob normally. Maybe u should official email from google. – Mr Special May 23 '20 at 10:28
  • @MrSpecial I got official email from google, about account activation, but I received an official letter from Google about the activation of the account, but the ad never shows (test ad is shown) – pinkcat May 23 '20 at 12:12
  • my app is on play store from the last 10 days. still it is not showing adds.. getting the same error failed to load the add with code 0. – Irfan Yaqub May 28 '20 at 20:09
  • I was wondering if you could give me some insight on this: When I first run my app on emulator, it shows `Failed to load ad: 1` then after some time it changes to `Failed to load ad: 3`. What does this mean? – parth shukla Jul 02 '20 at 06:23
  • You also need to set a payment profile in Admob's settings (just the business/person name, there is no need for bank details until you reach the earnings threshold). – Tomasz Jul 02 '20 at 21:52
40

In my case missing payment information was an issue. When you login to Admob dashboard you will see notice over there which says ads won't work until we add payment details.

Hardik Maru
  • 661
  • 5
  • 8
9

Constant Value: 0

This error generally occurs in newly created ads. So wait for few hours for the ads to be loaded.

Rohit Lalwani
  • 529
  • 7
  • 14
7

So I had the same error, I have tried everything listed here first.

  1. Waiting for google to send me an email saying AdMob is active. Done, it took about an hour, in fact, if you log in it will give you the status, then I waited for 48~ hours, and still the same issue

  2. The payment setup was not an issue for me because I got paid from an associated AdSense account before.

  3. Then I read all the possible common setup issues that other users here had. I mostly used the sample Admob App ID

    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-3940256099942544~3347511713"/>
    

And the Sample ad Unit Id given on the Admob getting started page, this way you eliminate issues with your account during development.

  1. I Was fairly sure that I had the configuration correct, but to check I downloaded Google's ad samples from GitHub. This way you can check working code, and pop your Admob App ID in and see if the account is set up correctly
  2. I started playing with the build.gradle of their sample, matching what I got to theirs, just updating and adding my dependencies. then I found it, as soon as I went to targetSdkVersion 30 and compileSdkVersion 30 the error arises. so, for now, I'm on SDK 29, till they fix this. I hope some found this useful

Edit: The issue is reported to google check the status here, and here. it seems to affect Java and Kotlin

Donovan Phoenix
  • 1,351
  • 1
  • 10
  • 8
6

It also happens when trying to request an ad from a placement with different type. For example, banner from interstitial and so on. I hope this will help somenone.

Artem Mostyaev
  • 3,874
  • 10
  • 53
  • 60
4

In my case I had enabled Debug logging for ads previously and this ironically caused them not to work...

Go to your device's settings > Google > Ads > Enable debug logging for ads (Disable)

It can also help if you choose Reset advertising ID on the top.

After this Test Ads started working again.

Good luck!

DJTano
  • 1,055
  • 12
  • 12
3

From the Documentation, Error code 0 means Internal error.

public static final int ERROR_CODE_INTERNAL_ERROR

Something happened internally; for instance, an invalid response was received from the ad server.

Constant Value: 0

This error generally occurs in newly created ads. So wait for few hours for the ads to be loaded.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
2

It also happened to me that error"fail to load ad 0" but there is no problem just wait for sometimes like an hour or 2 or even 5 hours just wait you will get the ads.

mzeesaid
  • 21
  • 1
2

You can always run your project on emulator and you will get information about "emulated ad" in your applicaiton

Rodriquez
  • 981
  • 1
  • 7
  • 21
1

When it works with the sample ad unit Ids your account probably just is not approved yet. Have you created it just now?

Test ads worked right away for me. I had to wait several hours for the "Great news – your account is now approved" mail until my ads worked too. Do not use your own ads for development anyway - you can get your AdMob account blocked for that!

So as soon as the test ads work and you have confirmed that the correct IDs are used for release build you most probably have done everything right and just have to wait

There is also an test App ID "ca-app-pub-3940256099942544~3347511713" but I had no problem to use my own App ID right after creating it.

Matthias
  • 1,267
  • 1
  • 15
  • 27
  • 3
    "Do not use your own ads for development anyway". You can also add your device as a test device if you want to test real ads. https://developers.google.com/admob/android/test-ads#enable_test_devices – Sadda Hussain Jul 02 '19 at 06:45
1

I had this issues because of AVD settings. Try to change AVD for debug or try to use real device.

Yuliia Ashomok
  • 8,336
  • 2
  • 60
  • 69
0

I know this question is from 4 years ago, but I stumbled on this because I was having the same error code. My problem is caused by using my own app-id instead of test app id in the manifest file. Once I changed it to the test-app id, I got error-code 2 instead. It's because DNS is not configured properly in my environment. So anyone having the same issue, make sure you are using correct app id and DNS is configured (Follow this link on how to set it up - Android emulator not able to access the internet)

KMC
  • 1,677
  • 3
  • 26
  • 55
0

In my case, the android phone that I used to test is Chinese phone and doesn't come with Google Service installed and have issues sometimes whiel using Google services. I have to manullay uninstall and install it again. And it solves the problem.

Khay Leng
  • 391
  • 5
  • 8
0

I had poor internet connection, and i had to wait sometime to load a video ad.

Bensal
  • 3,316
  • 1
  • 23
  • 35
0

My two cents: This error also happens when you don't have a working internet connection.

Mahesh Jamdade
  • 17,235
  • 8
  • 110
  • 131
0

The resolution for me was in my Proguard configuration. I had the first line originally, but I was missing the second line.

-keep class com.google.android.gms.ads.** { *; }
-keep class com.google.ads.** { *; }
BurkusCat
  • 41
  • 7
-2

Open the build.gradle file inside your application module directory:

and add this dependency

dependencies {
......
......
  implementation 'com.google.android.gms:play-services-ads:19.2.0'
}
Abir Ahsan
  • 2,649
  • 29
  • 51