Failed to load custom ad: 0 Error

I am implementing the code for native ads provided by google. This works fine google

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

But when I replace my identifier, it won’t show the ad and execute the onAdFailedToLoad method and it didn’t receive. Unable to load own ad: error 0 .

 I tried two different ad unit id but it didn't load ad. so what should I do??please help me 

I tried under the 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()); 
+5
source share
2 answers

Please add at least one testing device and try. Perhaps the following will help you:

 AdRequest adRequest = new AdRequest.Builder() .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID") .build(); 
0
source

this could be answered recently, but expecting help from others having a similar problem. One of the main reasons for this is incorrect measurement.

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 made a mistake in providing adSize, so I just resized the added size and got the fix. Thanks.

  ads:adSize="320x250" 
0
source

All Articles