我一直在努力更新到需要谷歌服务才能运行的新AdMob。 我使用的onCreate()这个代码升级AdMob SDK并加载失败()方法
AdView adView = (AdView)this.findViewById(R.id.adView);
//AdRequest
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
adView.loadAd(adRequest);
Log.d("ADMOB", "Successfully loaded");
和我在XML
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal"
ads:adSize="SMART_BANNER"
ads:adUnitId="ADMOB_ID"/>
使用此代码然而,AdMob广告不会显示。在try/catch块无法在这里:
adView.loadAd(adRequest);
的AndroidManifest代码如下所示:
<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" />
我缺少什么?
你是什么意思 “的try/catch块无法在这里:”。它会抛出异常吗?如果是这样,请发布。如果它是一个NullPointerException,那么这意味着它没有找到你的AdView。 – William 2014-10-08 21:43:04
没有NPE事实上,它只列出了我插入的调试内容,它显示它在build()时失败。由于模拟器似乎没有正常工作,我即将尝试使用真实设备。 – 2014-10-09 11:47:48
你是什么意思'失败build()'。有什么症状?它如何失败? – William 2014-10-09 12:32:47