Failed to load Native ad: 0 Error
Asked Answered
B

2

6

I am implementing code for native ads that is given by google. That is working okay with google

ad unit id ADMOB_AD_UNIT_ID = "ca-app-pub-3940256099942544/2247696110"

But when I replace with my id its not showing ad and execute onAdFailedToLoad method and got Failed to load native ad: 0 error .

I tried two different ad unit id but it didn't load ad.

so what should I do??please help me 

I tried below code

final LayoutInflater li = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            AdLoader.Builder builder = new AdLoader.Builder(appContext, Global.ADMOB_AD_UNIT_ID);

            builder.forContentAd(new NativeContentAd.OnContentAdLoadedListener() {
                @Override
                public void onContentAdLoaded(NativeContentAd ad) {
                    //viewHolder.rlnativead.setVisibility(View.VISIBLE);
                    NativeContentAdView adView = (NativeContentAdView)li
                            .inflate(R.layout.ad_content, null);
                    populateContentAdView(ad, adView);
                    viewHolder.fl_adplaceholder.removeAllViews();
                    viewHolder.fl_adplaceholder.addView(adView);
                }
            });

            AdLoader adLoader = builder.withAdListener(new AdListener() {
                @Override
                public void onAdFailedToLoad(int errorCode) {
//                  Toast.makeText(appContext, "Failed to load native ad: "
//                          + errorCode, Toast.LENGTH_SHORT).show();
                    Log.e("Call List adapter","Failed to load native ad: "+errorCode);
                }
            }).build();

            adLoader.loadAd(new AdRequest.Builder().build());
Boyceboycey answered 22/6, 2016 at 10:48 Comment(1)
i got solution friends..this ADMOB_AD_UNIT_ID is for native expressview so it will only use by native expressview .we can not use for advance native view currently native ad is in under betaBoyceboycey
M
0

Please add at least one testing device and try, It may be help you like following,

AdRequest adRequest = new AdRequest.Builder() .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID") .build();
Memento answered 22/6, 2016 at 12:42 Comment(0)
N
0

this could be lately answered but expecting to help for others having similiar problem.One of the major cause for this is incorrect dimension

In my case before it was

 <?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.NativeExpressAdView android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adUnitId="@string/native_ad_id"
    ads:adSize="320x250"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto">
</com.google.android.gms.ads.NativeExpressAdView>

I was making the mistake in giving the adSize ,so i just changed the add size with the below dimension and got fixed. Thanks.

 ads:adSize="320x250"
Nutter answered 10/4, 2017 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.