0
votes

Previously whenever I tested ads, I just used the live ad unit ids from Admob. If I run the app in emulator it used to load ad as SCREEN1 shown below (without TestAd Text overlapping it). And if I run the app in device it will show ads of different ad publishers.

But when I tried to do same today. If I use live ad unit ids then adview will show up as blank (as in SCREEN 2) and it will throw these information in logcat.

I/Ads: No fill from ad server.
W/Ads: Failed to load ad: 3

If I use test ad unit id's provided by google as shown in https://developers.google.com/admob/android/test-ads then it will load up ad as shown in SCREEN1.

SCREEN 1:

Ad is loading up with Test Banner ID

enter image description here

SCREEN 2:

Ad is not loading up with Admob banner ad id

enter image description here

There must be no issue in code since it's loading ads with Test Ad Unit ids but here is the code that I have used below to load the ad.

Code to load banner Id:

mAdView = findViewById(R.id.adView) as AdView
val adRequest = AdRequest.Builder().build()
mAdView.loadAd(adRequest)

BannerView In layout:

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    ads:adSize="SMART_BANNER"
    ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
    ads:layout_constraintEnd_toEndOf="parent"
    ads:layout_constraintStart_toStartOf="parent"
    ads:layout_constraintTop_toTopOf="parent"> 
</com.google.android.gms.ads.AdView>
4
Share some code so that we can understand the problem better.Reaz Murshed
It takes some time to Load / Activate the Ads on the Device after creating the Ad Unit... Sometimes, there is No Ad served && therefore nothin is displayed but this happens very rarely... Alsock the Logcat, it will show maybe why the Ad isn't loadingDarShan

4 Answers

0
votes

Maybe the reason is you AdMob Id is suspended,
So please try with another adUnit Id,
The reason for the suspension is maybe you showing Ad without adding the testing device to many time with the same device.
Another reason is when your app is suspended from play store some time addUnit Id also suspend.

0
votes

Try this code for load banner

mAdView = (AdView) findViewById(R.id.adView);
                adRequest = new AdRequest.Builder()
                        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                        .build();
                mAdView.setAdListener(new com.google.android.gms.ads.AdListener() {
                    @Override
                    public void onAdLoaded() {
                        super.onAdLoaded();
                    }
                });
                mAdView.loadAd(adRequest);

And set height android:layout_height="wrap_content" in layout.

0
votes

Follow below link :

Try to generate new unit Id.For the first time, it takes some time to appear.

http://androtech1tk.000webhostapp.com/2017/09/adding-google-admob-ads-to-android-app

0
votes

You can only test ads on emulator or on device using Test Ad Unit Ids now. You can get Test Ad Unit Ids here:

https://developers.google.com/admob/android/test-ads

If you want to test Ads with live Ad Unit Ids then you can only do that after you generate signed APK and install it in device.

NOTE:

If you use live Ad Unit Id's while testing unsigned apks it will come up blank.