'Admob ads not showing in the real device although its working on the Emulator

I am having the Admob problem its working fine with test AppId and AdUnitId on emulator and real device. both the devices show the "Nice Job" test Ads

After creating my AppId and My AdUnitId the emulator is showing next level ads and working but the real device don't show anything. no adview bar in the real device

My codes are as below-

build.gradle ModuleApp

dependencies { ...
implementation 'com.google.android.gms:play-services-ads:18.3.0' }

AndroidManifest.xml

<application  
      ...         
     <meta-data           android:name="com.google.android.gms.ads.APPLICATION_ID"             
      android:value="@string/xsAdmobMyAppId"/>    
</application>

activity_current.xml

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"

    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"

    app:adSize="BANNER"
    app:adUnitId="@string/xsAdmobMyBannerUnitId">

</com.google.android.gms.ads.AdView>

CurrentActivity.java inside onCreate()

MobileAds.initialize(this, new OnInitializationCompleteListener() {
    @Override
    public void onInitializationComplete(InitializationStatus initializationStatus) {
    }
});

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

AdRequest adRequest = new AdRequest.Builder()
        .build();
mAdView.loadAd(adRequest);

One more query: It is shown in the developers.google.com get started information to add the MobileAds.initialize{...} What is the requirement of this, as the app is working still working even if the code is not added.

I found some similar questions on the web but didn't find/understand the proper solution.



Solution 1:[1]

If anyone stumble on this issue, when you are using physical device you are required to use test device id generated in logs instead of demo ad unit. Based on experience you no longer need to use demo ad unit both on physical and emulator during development. Production Ad Unit will also not show up in debug build on physical device, while using an emulator will automatically convert it to Test Ad so you are safe from violation.

Solution 2:[2]

Add the listener to your AdView to get more informations why it is not possible to load ads.

mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
    // Code to be executed when an ad finishes loading.
}

@Override
public void onAdFailedToLoad(int errorCode) {
    Log.d("mAdView", "onAdFailedToLoad. But why? "+errorCode)
    // Code to be executed when an ad request fails.
}

@Override
public void onAdOpened() {
    // Code to be executed when an ad opens an overlay that
    // covers the screen.
}

@Override
public void onAdClicked() {
    // Code to be executed when the user clicks on an ad.
}

@Override
public void onAdLeftApplication() {
    // Code to be executed when the user has left the app.
}

@Override
public void onAdClosed() {
    // Code to be executed when the user is about to return
    // to the app after tapping on an ad.
}
});

And you should add some output to your initialization.

MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
Log.d("MobileAds", "#onInitializationComplete");
}
});

Solution 3:[3]

After 1 month only 2 times the ad was loaded in my app. I have still not distributed the app. All the requests and the 2 Loadings are showing in my AdMobs Dashboard.

So now I suggest following 2 answers to my own question 1) Google AdMobs is not having the banner ads to load. 2) Google AdMobs is not loading the ads on the new apps and it wait for multiple requests from multiple installed app to start loading the ads. This may be to avoid any misuse.

If someone else also has the same judgement then do refer this answer to them as everyone will just be wasting a lot of time in editing the codes although the code is perfectly fine.

As suggested by Mr S.Gissel above, I had already tried the AdView Listeners and the error code was 3 i.e. no ad to load.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 S. Gissel
Solution 3 Sundeep