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:

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. I even tried making multiple different ads for different applications (different adID's and still got the same results)

 <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 :

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 )

I also updated the Google Play Services from the SDK manager and I get this in the 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. After I ran my app I went to my AdMob account and noticed that there are 0 AdMob network requests. Any help would be greatly appreciated!


According to 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.


It appears that the custom ROM that I had installed on my phone contained an AdBlock plugin. So I changed to Cyanogenmod and had no further issues.

链接地址: http://www.djcxy.com/p/32276.html

上一篇: 为什么在iPhone应用程序发布之前我得到了admob点击

下一篇: 无法让AdMob在Android上工作:ErrorCode 0