无法让AdMob在Android上运行:ErrorCode 0

时间:2015-09-27 22:04:02

标签: java android admob error-code banner-ads

我对此非常绝望。我按照谷歌在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' s仍然得到相同的结果)

 <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&#39; 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网络请求。 非常感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

根据谷歌的说法:

Something happened internally; for instance, an invalid response was received from the ad server.

我不确定你可以在这做什么。 查看链接Banner AdsAdRequest Class

答案 1 :(得分:0)

我手机上安装的自定义ROM似乎包含一个AdBlock插件。所以我改为Cyanogenmod,没有进一步的问题。