I keep getting this error on loading of Interstitial ads

K

kfir

Guest
keep getting this error on loading of Interstitial ads

Before it crashed the app. since I have apply mInterstitial = null on destroy - it didn;t crash error still appear in the log.

how to properly destroy the mInterstitial? there is no mInterstitial.Destroy. mInterstitial = null is enough?

error started since I have integrated Unity ads.

10-06 09:21:20.761 3310-4585/? E/Ads: Unable to invokeJavascript
java.lang.NullPointerException: Attempt to invoke interface method 'org.json.JSONObject com.google.android.gms.internal.ads.zzaiq.zzj(java.lang.Object)' on a null object reference
at com.google.android.gms.internal.ads.zzaiy.zza(com.google.android.gms:p[email protected]@18.2.0:6)
at com.google.android.gms.internal.ads.zzajb.zzh(com.google.android.gms:p[email protected]@18.2.0:3)
at com.google.android.gms.internal.ads.zzaye.onSuccess(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzdda.run(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcq.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzaxs.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzdby.zza(com.google.android.gms:p[email protected]@18.2.0:39)
at com.google.android.gms.internal.ads.zzdby.addListener(com.google.android.gms:p[email protected]@18.2.0:11)
at com.google.android.gms.internal.ads.zzaxv.addListener(com.google.android.gms:p[email protected]@18.2.0:1)
at androidx.transition.ViewGroupUtilsApi18.zza(ViewGroupUtilsApi18.java:449)
at com.google.android.gms.internal.ads.zzaiy.zzi(com.google.android.gms:p[email protected]@18.2.0:7)
at com.google.android.gms.ads.internal.zzd.zza(com.google.android.gms:p[email protected]@18.2.0:30)
at com.google.android.gms.ads.internal.zzd.zza(com.google.android.gms:p[email protected]@18.2.0:39)
at com.google.android.gms.internal.ads.zzbmd.zzb(com.google.android.gms:p[email protected]@18.2.0:7)
at com.google.android.gms.internal.ads.zzbpa.zzp(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzbpl.run(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcq.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzaxs.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzbpm.zza(com.google.android.gms:p[email protected]@18.2.0:8)
at com.google.android.gms.internal.ads.zzbox.zzb(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzcdr.zzf(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcd.zzc(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdca.run(com.google.android.gms:p[email protected]@18.2.0:9)
at com.google.android.gms.internal.ads.zzddm.run(com.google.android.gms:p[email protected]@18.2.0:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
10-06 09:21:21.011 3310-3310/? E/ViewSystem: ViewRootImpl #2 Surface is not valid.

10-06 09:23:11.711 3310-4793/? E/Ads: Unable to invokeJavascript
java.lang.NullPointerException: Attempt to invoke interface method 'org.json.JSONObject com.google.android.gms.internal.ads.zzaiq.zzj(java.lang.Object)' on a null object reference
at com.google.android.gms.internal.ads.zzaiy.zza(com.google.android.gms:p[email protected]@18.2.0:6)
at com.google.android.gms.internal.ads.zzajb.zzh(com.google.android.gms:p[email protected]@18.2.0:3)
at com.google.android.gms.internal.ads.zzaye.onSuccess(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzdda.run(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcq.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzaxs.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzdby.zza(com.google.android.gms:p[email protected]@18.2.0:39)
at com.google.android.gms.internal.ads.zzdby.addListener(com.google.android.gms:p[email protected]@18.2.0:11)
at com.google.android.gms.internal.ads.zzaxv.addListener(com.google.android.gms:p[email protected]@18.2.0:1)
at androidx.transition.ViewGroupUtilsApi18.zza(ViewGroupUtilsApi18.java:449)
at com.google.android.gms.internal.ads.zzaiy.zzi(com.google.android.gms:p[email protected]@18.2.0:7)
at com.google.android.gms.ads.internal.zzd.zza(com.google.android.gms:p[email protected]@18.2.0:30)
at com.google.android.gms.ads.internal.zzd.zza(com.google.android.gms:p[email protected]@18.2.0:39)
at com.google.android.gms.internal.ads.zzbmd.zzb(com.google.android.gms:p[email protected]@18.2.0:7)
at com.google.android.gms.internal.ads.zzbpa.zzp(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzbpl.run(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcq.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzaxs.execute(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzbpm.zza(com.google.android.gms:p[email protected]@18.2.0:8)
at com.google.android.gms.internal.ads.zzbox.zzb(com.google.android.gms:p[email protected]@18.2.0:1)
at com.google.android.gms.internal.ads.zzcdr.zzf(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdcd.zzc(com.google.android.gms:p[email protected]@18.2.0:2)
at com.google.android.gms.internal.ads.zzdca.run(com.google.android.gms:p[email protected]@18.2.0:9)
at com.google.android.gms.internal.ads.zzddm.run(com.google.android.gms:p[email protected]@18.2.0:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
10-06 09:23:13.331 3310-3310/? E/UnityMediationAdapter: An ad is already loading for placement ID: admobInterstitialID
10-06 09:23:13.331 3310-3310/? E/UnityMediationAdapter: Failed to load Interstitial ad from Unity Ads: INTERNAL_ERROR
10-06 09:23:13.451 3310-3389/? E/chromium: [ERROR:tile_manager.cc(779)] WARNING: tile memory limits exceeded, some content may not draw


This is my code

mAdView = findViewById(R.id.ad_view);

RequestConfiguration conf = MobileAds.getRequestConfiguration().toBuilder()
.setTagForChildDirectedTreatment(TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE)
.setTagForUnderAgeOfConsent(TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE)
.setMaxAdContentRating(MAX_AD_CONTENT_RATING_G)
.build();
MobileAds.setRequestConfiguration(conf);

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


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


mAdView.loadAd(adRequest);


mInterstitialAd = new InterstitialAd(this);

mInterstitialAd.setAdUnitId("ca-app-pub-xxxxxxxxxxxx/xxxxxxxxx");

mInterstitialAd.setAdListener(new AdListener()
{
@Override
public void onAdLoaded()
{
//log interstitial loaded
}
@Override
public void onAdFailedToLoad(int errorCode)
{
Log.d(TAG, "onAdFailedToLoad : errorcode : " + String.valueOf(errorCode));
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdClosed()
{

AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
// Ad interstitialAd reLoaded
Log.d(TAG, "Ad interstitialAd reLoaded");
super.onAdClosed();
}
});
mInterstitialAd.loadAd(new AdRequest.Builder().build());

@Override protected void onDestroy() {
super.onDestroy();
try {
if (mAdView != null) {
mAdView.setAdListener(null);
if (adscontainerWait != null)
adscontainerWait.removeAllViews();
mAdView.destroy();

}
mInterstitialAd = null;

} catch (Exception ex) {
Log.d(TAG, ex.toString());
}
}

Continue reading...
 
Top