GooglePlayServices Admob issue: "Failed to load ad: 0"

I have a problem with the new admob.

Here is my code that is trying to create and load an ad in my main activity:

private void createAndLoadAd(String adUnitID, RelativeLayout rlRoot, View upperView){ adView = new AdView(this); adView.setAdUnitId(adUnitID); adView.setAdSize(AdSize.BANNER); adView.setId(R.id.ad_view); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(AdView.LayoutParams.WRAP_CONTENT, AdView.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); rlRoot.addView(adView, params); RelativeLayout.LayoutParams upperViewParams = (RelativeLayout.LayoutParams) upperView.getLayoutParams(); upperViewParams.addRule(RelativeLayout.ABOVE, R.id.ad_view); upperView.setLayoutParams(upperViewParams); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); checkGooglePlayServices(this); } 

I have a RelativeLayout in my XML, and I'm trying to place an ad just below the ExpandableListView (only a child).

Here is what I get:

W / Ads: Failed to get ad response. ErrorCode: 0 W / Ads:

Failed to load ad: 0

I know for sure that I have all the necessary permissions in AndroidManifest.xml:

 <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> 

And here is the gradle line:

 compile 'com.google.android.gms:play-services:6.+' 

I read that an error may occur from adUnitID, I tried to recreate a new one, but it did not work.

Perhaps there are some new rules that, if the application is not released on the market, the ads will not work?

Here is the issue log:

 01-31 09:48:37.687 19580-19580/me.frozened.rappel I/Ads﹕ Starting ad request. 01-31 09:48:37.872 19580-19580/me.frozened.rappel E/﹕ file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt: not found! 01-31 09:48:37.872 19580-19580/me.frozened.rappel I/﹕ Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl 01-31 09:48:37.887 19580-19580/me.frozened.rappel I/﹕ Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl 01-31 09:48:37.912 19580-19580/me.frozened.rappel I/﹕ Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl 01-31 09:48:40.767 19580-19580/me.frozened.rappel W/KeyCharacterMap﹕ Load KCM of non-default device may incur unexpected result 01-31 09:48:48.217 19580-19617/me.frozened.rappel W/Ads﹕ There was a problem getting an ad response. ErrorCode: 0 01-31 09:48:48.222 19580-19580/me.frozened.rappel W/dalvikvm﹕ VFY: unable to resolve virtual method 3114: Landroid/webkit/WebView;.evaluateJavascript (Ljava/lang/String;Landroid/webkit/ValueCallback;)V 01-31 09:48:48.302 19580-19833/me.frozened.rappel W/﹕ init htc webcore 01-31 09:48:48.337 19580-19580/me.frozened.rappel W/Ads﹕ Failed to load ad: 0 

Edit:

The problem does not seem to be isolated. I did a lot of tests, and out of ten of my tests, only two worked. I do not understand, maybe the new admob does not work very well?

I tested these applications on the following devices:

  • HTC One X <- Doesn't work (logs for this)
  • Nexus 5 <- Working
  • Samsung Galaxy Note 10.1 <- Doesn't work
  • Sasmung Galaxy Ace <- Doesn't work
  • Samsung Galaxy Note 3 <- Doesn't Work
  • Sony Xperia Z <- Working
  • Samsung Galaxy Alpha <- Doesn't Work
  • Samsung Galaxy S3 <- Doesn't work

Some of these phones use the latest version of Google Play Services (my HTC One X, my Nexus 5, Galaxy Note 3). I do not know others.

Here are two tested applications: - Rappel <- The first problematic application - My Word Book <- an old application with which I am sure that the ads worked before - BMI <- an application for friends in the same situation

So, I have two hypotheses: either I tested these applications on phones that do not work very well (I would believe it ...), or there is some kind of permission / code that I forgot to add.

In addition, my HTC One X does not have a SIM card (I use only the Internet). Maybe this is a problem for this phone?

+5
source share
3 answers

Actually, my code was right, and I had an updated library of Google Play services in my android. My admob account was new with new banner and firewall id

It is automatically fixed and begins to receive an ad response after waiting 1-2 days. Everything has been working well ever since.

+2
source

In my case, I forget to use

.addTestDevice("1C51F744DXXXXXXXX64F06586C84EF")

You will receive the identifier of your device in the log.

+1
source

This can also happen if you use a custom ROM , for example CyanogenMod , which does not come with Google applications ( G-Apps >), like the Play Store, Gmail, by default.

So you have to:

If you made the encoding correctly, the ads should now be displayed.

0
source

Source: https://habr.com/ru/post/1210356/


All Articles