0

我对此感到非常绝望。我按照谷歌在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" />

摇篮的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 网络请求。 任何帮助将不胜感激!

4

2 回答 2

0

根据谷歌:

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

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

于 2015-09-27T23:47:13.847 回答
0

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

于 2016-04-26T21:27:19.437 回答