GooglePlayServices Admob问题:“无法加载广告:0” [英] GooglePlayServices Admob issue : "Failed to load ad : 0"
问题描述
我的新admob存在问题。
这是我的代码,尝试在我的主要活动中创建和加载广告:
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);
}
在我的XML中有一个RelativeLayout,我试图放置广告位于ExpandableListView(仅儿童)的下方。
以下是我得到的结果:
W /广告:获得广告响应时出现问题。 ErrorCode:0 W / Ads:
无法加载广告:0
我确切地说我拥有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/>
这里是gradle行:
compile'com.google.android.gms:play-services:6. +'
我读到这个错误可能来自adUnitID,我试图重新创建一个新的但没有工作。
也许有一些新的规则,如果应用程序没有在市场上发布,广告将无法正常工作?
以下是有关问题的日志:
01-31 09:48:37.687 19580-19580 / me.frozened.rappel I /广告:开始广告请求。
01-31 09:48:37.872 19580-19580 / me.frozened.rappel E:/ file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt:找不到!
01-31 09:48:37.872 19580-19580 / me.frozened.rappel I /:尝试加载EGL实现/ system / lib // egl / libEGL_tegra_impl
01-31 09:48:37.887 19580-19580 / me.frozened.rappel I /:加载的EGL实现/ system / lib // egl / libEGL_tegra_impl
01-31 09:48:37.912 19580-19580 / me.frozened.rappel I /:加载GLESv2执行/ system / lib // egl / libGLESv2_tegra_impl
01-31 09:48:40.767 19580-19580 / me.frozened.rappel W / KeyCharacterMap:加载非默认设备的KCM可能会产生意外的结果
01-31 09:48:48.217 19580-19617 / me.frozened.rappel W /广告:获得广告回复时出现问题。 ErrorCode:0
01-31 09:48:48.222 19580-19580 / me.frozened.rappel W / dalvikvm:VFY:无法解析虚拟方法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 /广告:未能加载广告:0
编辑:
这个问题似乎并不孤立。我做了很多测试,从我的十个测试中,只有两个测试。我不明白,也许新的admob工作不太好?
我在以下设备上测试了这些应用程序:
- HTC One X < - 无法使用(日志适用于此版本)
- Nexus 5 < - Working
- Samsung Galaxy Note 10.1< - 无法使用
- Sasmung Galaxy Ace< - 无法正常工作
- Samsung Galaxy Note 3< ; - 无法正常工作
- Sony Xperia Z < - 工作
- Samsung Galaxy Alpha < - 不工作
li> Samsung Galaxy S3< - 无法使用
部分手机正在使用最新版本的Google Play服务(我的HTC One X,我的Nexus 5,Galaxy Note 3)。我不知道其他人。
以下是我测试的两个应用程序:
- Rappel < - 第一个有问题的应用程序
- My Word Book < - 一款旧应用程式,我确信广告在
- BMI < - 朋友的应用程序在同样的情况。
因此我有两个假设:要么我测试这些应用程序的手机工作不是很好(我会相信它......),或者有一些许可/代码我忘了添加。
另外,我的HTC One X没有SIM卡(我只使用互联网)。这可能是这款手机的问题吗?
其实,我的代码是正确的&我在我的android中有一个更新的谷歌播放服务库。我的admob帐户是新的横幅和新的横幅。 interstial id's
它自动得到修复&在等待1-2天后开始获得广告响应。从那以后一切正常。
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 ?
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.
这篇关于GooglePlayServices Admob问题:“无法加载广告:0”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!