2

I have implemented Admob in my app and working well with test ads. I am loading ads in feed list, and getting error " Failed to load Ad: 0". According to Stack Overflow answers, this error mostly related to newly created ad units, but it had been more than 15 days but getting the same error. While rewarded video ad unit is working fine. Admob account is also with approved status. Asked the same question in Google Admob Community, but no answer.

Don't mark it duplicate of this question as the accepted answer says to wait, but in my case, I am waiting for last 15 days.

Here is code snippet.

private void showNativeGoogleAd(UnifiedNativeAdViewHolder holder)
{
    AdLoader adLoader = new AdLoader.Builder(mContext, mContext.getString(R.string.admob_social_wall_ad_unit_id))
    //AdLoader adLoader = new AdLoader.Builder(mContext, "ca-app-pub-3940256099942544/1044960115")
            .forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
                @Override
                public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
                    // Show the ad.
                    populateNativeAdView(unifiedNativeAd, holder.adView);
                    //holder.fl_adplaceholder.removeAllViews();
                    //holder.fl_adplaceholder.addView(holder.adView);
                }
            })
            .withAdListener(new AdListener() {
                @Override
                public void onAdFailedToLoad(int errorCode) {
                    // Handle the failure by logging, altering the UI, and so on.
                    Log.d("TAG", "onAdFailedToLoad: Google => "+errorCode);
                }
            })
            .withNativeAdOptions(new NativeAdOptions.Builder()
                    // Methods in the NativeAdOptions.Builder class can be
                    // used here to specify individual options settings.
                    .build())
            .build();

    adLoader.loadAd(new AdRequest.Builder().build());
}

private void populateNativeAdView(UnifiedNativeAd nativeAd,
                                  UnifiedNativeAdView adView) {
    // Some assets are guaranteed to be in every UnifiedNativeAd.
    ((TextView) adView.getHeadlineView()).setText(nativeAd.getHeadline());
    ((TextView) adView.getBodyView()).setText(nativeAd.getBody());
    ((Button) adView.getCallToActionView()).setText(nativeAd.getCallToAction());

    // These assets aren't guaranteed to be in every UnifiedNativeAd, so it's important to
    // check before trying to display them.
    com.google.android.gms.ads.formats.NativeAd.Image icon = nativeAd.getIcon();

    if (icon == null) {
        adView.getIconView().setVisibility(View.INVISIBLE);
    } else {
        ((ImageView) adView.getIconView()).setImageDrawable(icon.getDrawable());
        adView.getIconView().setVisibility(View.VISIBLE);
    }

    if (nativeAd.getPrice() == null) {
        adView.getPriceView().setVisibility(View.INVISIBLE);
    } else {
        adView.getPriceView().setVisibility(View.VISIBLE);
        ((TextView) adView.getPriceView()).setText(nativeAd.getPrice());
    }

    if (nativeAd.getStore() == null) {
        adView.getStoreView().setVisibility(View.INVISIBLE);
    } else {
        adView.getStoreView().setVisibility(View.VISIBLE);
        ((TextView) adView.getStoreView()).setText(nativeAd.getStore());
    }

    if (nativeAd.getStarRating() == null) {
        adView.getStarRatingView().setVisibility(View.INVISIBLE);
    } else {
        ((RatingBar) adView.getStarRatingView())
                .setRating(nativeAd.getStarRating().floatValue());
        adView.getStarRatingView().setVisibility(View.VISIBLE);
    }

    if (nativeAd.getAdvertiser() == null) {
        adView.getAdvertiserView().setVisibility(View.INVISIBLE);
    } else {
        ((TextView) adView.getAdvertiserView()).setText(nativeAd.getAdvertiser());
        adView.getAdvertiserView().setVisibility(View.VISIBLE);
    }

    // Assign native ad object to the native view.
    adView.setNativeAd(nativeAd);
}
Manish Dubey
  • 4,206
  • 8
  • 36
  • 65
  • Possible duplicate of [Admob ads not loading - Failed to load ad: 0](https://stackoverflow.com/questions/38378002/admob-ads-not-loading-failed-to-load-ad-0) – Martin Zeitler Jun 13 '19 at 19:26
  • have you tried creating a new ad unit and see if it shows ad? Also is account newly created? If so please check if payment method is set correctly and address is verified – Amod Gokhale Jun 14 '19 at 05:31
  • @AmodGokhale Account is 2 months old, not working with the newly created unit also. Test ad is loading fine. The rewarded video ad is loading fine, but the banner ad in feed is not loading. I tried with 3 different banner ad unit ids. – Manish Dubey Jun 14 '19 at 07:37
  • are there any ad blocker installed on targeted device or wifi? Another check is to convert banner to to smart-banner? Also i assume app you are trying to show is live in play store and not in beta... If its live kindly link app in admob.. Also please update your question with code – Amod Gokhale Jun 14 '19 at 08:43
  • I am testing on a real device, no ad-blocker installed. Where to change the banner to smart-banner, I am not getting it? I am using native ad view to load native ad in list. Is there any option to change the banner to smart-banner in ad console? Also, the app is published in production not in beta on Play Store. – Manish Dubey Jun 18 '19 at 10:15

0 Answers0