Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a problem with the new admob.

Here is my code, 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 the ad just below an ExpandableListView (only child).

Here is what I get :

W/Ads﹕ There was a problem getting an ad response. ErrorCode: 0 W/Ads﹕

Failed to load ad: 0

I precise that I have all the permission needed in my 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 the error may come from the adUnitID, I tried to recreate a new one but didn't work.

Maybe there is some new rules that if the application is not released in the market, ads won't work ?

Here is the log concerning the problem :

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 seems to be not isolated. I did a lot of tests, and from my ten tests, only two worked. I don't understand, maybe the new admob is not working very well ?

I tested these applications on the following devices :

  • HTC One X <- Not working (the logs are for this one)
  • Nexus 5 <- Working
  • Samsung Galaxy Note 10.1 <- Not working
  • Sasmung Galaxy Ace <- Not working
  • Samsung Galaxy Note 3 <- Not working
  • Sony Xperia Z <- Working
  • Samsung Galaxy Alpha <- Not Working
  • Samsung Galaxy S3 <- Not working

Some of theses phones are using the latest version of Google Play Services (my HTC One X, my Nexus 5, the Galaxy Note 3). I don't know for the other ones.

Here are the two apps I tested : - Rappel <- The first problematic app - My Word Book <- An old app whom I'm sure the ads worked before - BMI <- A friend app in the same situation

So I have two hypothesis : either I tested these applications on phones who are not working very well (I would belive it...), or there is some permission/code I forgot to add.

Plus, my HTC One X doesn't have a SIM card (I only use Internet). May this be the problem for this phone ?

like image 562
FR073N Avatar asked Jan 04 '15 14:01

FR073N


2 Answers

Actually, my code was right & I was having an updated google play services library in my android. My admob account was new with new banner & interstial id's

It automatically got fixed & start getting the ad response after waiting 1-2 days. Since then everything works well.

like image 70
Vivek Warde Avatar answered Sep 29 '22 20:09

Vivek Warde


In My case i forget to use

.addTestDevice("1C51F744DXXXXXXXX64F06586C84EF")

You will get your device id in the log.

like image 22
Abhishek Kumar Avatar answered Sep 29 '22 21:09

Abhishek Kumar