简体   繁体   English

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

[英]Cannot get AdMob to work on Android : ErrorCode 0

I am getting really desperate with this. 我对此感到非常绝望。 I followed the given instructions by Google at the https://developers.google.com/admob/android/quick-start webpage but it still didn't work My code (or at least the part that has to do with AdMob) Instantiation in the menu.java class: 我按照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);

The Banner in XML For the "banner_ad_unit_id" I used the ID that I got from my AdMob account. XML中的横幅广告对于“ banner_ad_unit_id”,我使用从AdMob帐户中获得的ID。 I even tried making multiple different ads for different applications (different adID's and still got the same results) 我什至尝试为不同的应用制作多个不同的广告(不同的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"/>

My manifest snippet : 我的清单片段:

<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's build.gradle : 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'
}

And the minSDK is 21 (for testing purposes(but its > than 9 so it shouldn't be a problem ) 而minSDK是21(出于测试目的(但它大于9,所以应该不成问题))

I also updated the Google Play Services from the SDK manager and I get this in the logcat : 我还从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

The interesting part is that i get that error no matter what code I use : I even used Google's adMob example on https://github.com/googleads/googleads-mobile-android-examples and still got the same code in the LogCat. 有趣的是,无论使用什么代码,我都会收到该错误:我什至在https://github.com/googleads/googleads-mobile-android-examples上使用Google的adMob示例,但在LogCat中仍然得到了相同的代码。 After I ran my app I went to my AdMob account and noticed that there are 0 AdMob network requests. 运行应用后,我进入了AdMob帐户,发现有0个AdMob网络请求。 Any help would be greatly appreciated! 任何帮助将不胜感激!

According to Google: 根据Google的说法:

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

I am not sure what can be done here on your part. 我不确定您可以在这里做什么。 Check out the links Banner Ads and AdRequest Class . 查看链接横幅广告AdRequest类

It appears that the custom ROM that I had installed on my phone contained an AdBlock plugin. 我安装在手机上的自定义ROM似乎包含一个AdBlock插件。 So I changed to Cyanogenmod and had no further issues. 所以我换了Cyanogenmod,没有其他问题了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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