繁体   English   中英

无法使AdMob在Android上运行:错误代码0

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM