简体   繁体   中英

Admob Banner ad is not displaying

Ads are not showing. I have configured my device as a test unit.

MobileAds.initialize(getActivity(), new OnInitializationCompleteListener() {
        @Override
        public void onInitializationComplete(InitializationStatus initializationStatus) {
        }
    });
    //setup test device
    MobileAds.setRequestConfiguration(
            new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("A222ECB948AFB6D392596135E7D33D35"))
                    .build());
    mAdView = root.findViewById(R.id.adView);
    final AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    mAdView.setAdListener( new AdListener(){
        @Override
        public void onAdLoaded() {
            Log.i("nonsinglefragment","ad loaded");
            super.onAdLoaded();
        }

        @Override
        public void onAdFailedToLoad(int i) {
            Log.i("nonsinglefragment","ad load failed "+i);
            super.onAdFailedToLoad(i);
        }

    });

Xml code

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:adSize="BANNER"
    app:adUnitId="@string/ad_id1"/>

This is the logcat

I/Ads: Updating ad debug logging enablement.
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
W/Ads: Update ad debug logging enablement as false
I/Ads: Ad failed to load : 0
I/Ads: Ad failed to load : 0

Everything was working fine with google's sample test ids. The problem started when I implemented my unit ID.

Please make sure your Admob account is active. if it is active then you can wait for some hours sometimes Ads take time to appear.

this is what google documentation says:

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM