error using the admobs - java.lang.IllegalStateException android.view.ViewGroup.addViewInner

247 views
Skip to first unread message

Arbel Solutions

unread,
Oct 6, 2019, 3:33:02 AM10/6/19
to google-adm...@googlegroups.com
I keep getting this report from google play console:

java.lang.IllegalStateException

android.view.ViewGroup.addViewInner



java.lang.IllegalStateException:
at android.view.ViewGroup.addViewInner (ViewGroup.java:5034)
at android.view.ViewGroup.addView (ViewGroup.java:4865)
at android.view.ViewGroup.addView (ViewGroup.java:4805)
at android.view.ViewGroup.addView (ViewGroup.java:4778)
at com.google.android.gms.internal.ads.zzcmh.onSuccess (zzcmh.java:17)
at com.google.android.gms.internal.ads.zzdda.run (zzdda.java:13)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at com.google.android.gms.internal.ads.zzdac.zzb (zzdac.java:7)
at com.google.android.gms.internal.ads.zzauf.zzb (zzauf.java:8)
at com.google.android.gms.internal.ads.zzdac.dispatchMessage (zzdac.java:5)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6762)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)


and before:


java.lang.IllegalStateException:
at android.view.ViewGroup.addViewInner (ViewGroup.java:4659)
at android.view.ViewGroup.addView (ViewGroup.java:4495)
at android.view.ViewGroup.addView (ViewGroup.java:4436)
at android.view.ViewGroup.addView (ViewGroup.java:4409)
at com.google.android.gms.internal.ads.zzcmh.onSuccess (zzcmh.java:17)
at com.google.android.gms.internal.ads.zzdda.run (zzdda.java:13)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at com.google.android.gms.internal.ads.zzdac.zzb (zzdac.java:7)
at com.google.android.gms.internal.ads.zzauf.zzb (zzauf.java:8)
at com.google.android.gms.internal.ads.zzdac.dispatchMessage (zzdac.java:5)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:7325)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)



Not sure how to investigate it. - I think it happens when the admobs are loaded oncreate.

This errors started to appear when I started using mediation with unity. I have added Facebook ads also but it is still not available.


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());
}
}



Mobile Ads SDK Forum Advisor Prod

unread,
Oct 6, 2019, 11:42:25 PM10/6/19
to arbelso...@gmail.com, google-adm...@googlegroups.com

Hi there,

Thank you for reporting this to us. For me to further check this on my end, could you provide the details below via Reply privately to author option?

  • Ad Format (Banner, Interstitial, Rewarded, Native)
  • SDK Version
  • Project (or at least a test project) where the issue is reproducible

Regards,
Mark Albios
Mobile Ads SDK Team



ref:_00D1U1174p._5001UKMJQl:ref

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 7, 2019, 2:52:12 AM10/7/19
to arbelso...@gmail.com, google-adm...@googlegroups.com

Hi there,

Thank you for providing additional details of the issue. I've downloaded your app in the Play Store; however, I wasn't able to replicate the issue on my end. Could you also share your App Id/ Ad Unit Id? In addition, could you confirm if the issue is reproducible locally? It would be much appreciated if you can provide a sample project (with the issue reproduced) to me so I could further investigate on my end.

Please use Reply privately to author option to send the details privately.



Regards,
Mark Albios
Mobile Ads SDK Team



ref:_00D1U1174p._5001UKMJQl:ref

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 7, 2019, 6:18:23 AM10/7/19
to arbelso...@gmail.com, google-adm...@googlegroups.com

Hi there,

Thank you for sharing additional information about the issue. As per further checking, I can see that there are other publisher that had previously reported this issue with a sample project. With that said, I'll raise this information to our Engineering team as well and get back to you as soon as they provide their feedback.



Regards,
Mark Albios
Mobile Ads SDK Team



ref:_00D1U1174p._5001UKMJQl:ref

Sohaib Ahmed

unread,
Jul 16, 2025, 7:23:56 AM7/16/25
to Google Mobile Ads SDK Developers
I'm still getting this crash a lot.. Any Solution Yet?
Reply all
Reply to author
Forward
0 new messages