Skip to content Skip to sidebar Skip to footer

Banner Ad Is Not Showing For My Ad Unit Id , Android

i want to show banner add to my android application, it is showing banner add ,if i use google's test id ca-app-pub-3940256099942544/630097

Solution 1:

You should have to try this:

<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3490247194261556/7252350096" />

put this code in your java file:

AdViewmAdView= (AdView) findViewById(R.id.adView);
AdRequestadRequest=newAdRequest.Builder().build();
mAdView.loadAd(adRequest);

Advertise.display(getApplicationContext());
if (Utility.isOnline(this)) {
    AdViewadView= (AdView) this.findViewById(R.id.adView);
    adRequest = newAdRequest.Builder().build();
    adView.loadAd(adRequest);
}

Note:- if you created your Ad-Unit id just now and trying to use it instantly then it will not works because after the creation of Ad-Unit id it will take time up to 1 or 2 hours for activation from AdMob.

Solution 2:

Verify app-level build.gradle (excerpt)

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile'com.google.firebase:firebase-ads:10.2.1'
    }


apply plugin: 'com.google.gms.google-services'

Solution 3:

You can try

XML code

 <com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_weight="0"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

JAVA code

AdViewmAdView= (AdView) findViewById(R.id.adView);

    AdRequestadRequest=newAdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build();
    mAdView.loadAd(adRequest);

Android Manifest

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

Solution 4:

Making ad requests requires the networking permissions INTERNET and ACCESS_NETWORK_STATE, so these must also be declared in the manifest

Post a Comment for "Banner Ad Is Not Showing For My Ad Unit Id , Android"