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 :
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 ?
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.
In My case i forget to use
.addTestDevice("1C51F744DXXXXXXXX64F06586C84EF")
You will get your device id in the log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With