Search code examples
androidadmobbanner-ads

Admob Failed to load ad: 0


I created my adMob ad unit around 12 hours ago and implemented it like so:

XML:

    <com.google.android.gms.ads.AdView
    android:id="@+id/bannerAdView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-9378881698271837/3415450508">
</com.google.android.gms.ads.AdView>

MainActivity.java:

    bannerAd = (AdView) findViewById(R.id.bannerAdView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(MY_DEVICE_ID).build();
    bannerAd.loadAd(adRequest);

Gradle dependencies:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-ads:11.0.1'
compile 'com.google.android.gms:play-services-ads:11.0.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
testCompile 'junit:junit:4.12'

}

Manifest permissions:

    <uses-permission android:name="android.permission.INTERNET" />

I followed the Firebase and adMob integration documentation but it will not display ads on any device I run the app on.


Solution

  • if you connect with firebase than also add maven{url "https://maven.google.com"}in project module gradle and in admob account add the payment detail