[英]Cannot get AdMob to work on Android : ErrorCode 0
我對此感到非常絕望。 我按照Google在https://developers.google.com/admob/android/quick-start網頁上給出的說明進行了操作,但仍然無法正常工作我的代碼(或至少與AdMob有關的部分)在menu.java
類中:
AdView adView = (AdView) findViewById(R.id.myaddview); //add the cast
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
adView.loadAd(adRequest);
XML中的橫幅廣告對於“ banner_ad_unit_id”,我使用從AdMob帳戶中獲得的ID。 我什至嘗試為不同的應用制作多個不同的廣告(不同的adID並獲得相同的結果)
<com.google.android.gms.ads.AdView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
android:id="@+id/myaddview"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_below="@+id/button4"/>
我的清單片段:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<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" />
Gradle的build.gradle
:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
}
而minSDK是21(出於測試目的(但它大於9,所以應該不成問題))
我還從SDK管理器更新了Google Play服務,並在logcat中得到了它:
09-28 00:53:59.798 15533-15693/com.example.slaven.toplel W/Ads﹕ There was a problem getting an ad response. ErrorCode: 0
09-28 00:53:59.816 15533-15533/com.example.slaven.toplel W/Ads﹕ Failed to load ad: 0
有趣的是,無論使用什么代碼,我都會收到該錯誤:我什至在https://github.com/googleads/googleads-mobile-android-examples上使用Google的adMob示例,但在LogCat中仍然得到了相同的代碼。 運行應用后,我進入了AdMob帳戶,發現有0個AdMob網絡請求。 任何幫助將不勝感激!
根據Google的說法:
Something happened internally; for instance, an invalid response was received from the ad server.
我不確定您可以在這里做什么。 查看鏈接橫幅廣告和AdRequest類 。
我安裝在手機上的自定義ROM似乎包含一個AdBlock插件。 所以我換了Cyanogenmod,沒有其他問題了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.