The SDK is throwing IllegalStateException for some users




I’m getting an important quantity of crash reports related to an IllegalStateException being thrown by the SDK. This is the full stacktrace:

java.lang.IllegalStateException: Illegal state. at com.mopub.common.Preconditions.checkStateInternal( at com.mopub.common.Preconditions.checkState( at com.mopub.mraid.MraidController.getRootView( at com.mopub.mraid.MraidController.access$1200( at com.mopub.mraid.MraidController$ at com.mopub.mraid.MraidController$ScreenMetricsWaiter$WaitRequest.countDown( at com.mopub.mraid.MraidController$ScreenMetricsWaiter$WaitRequest.access$400( at com.mopub.mraid.MraidController$ScreenMetricsWaiter$WaitRequest$1$1.onPreDraw( at android.view.ViewTreeObserver.dispatchOnPreDraw( at android.view.ViewRootImpl.performTraversals( at android.view.ViewRootImpl.doTraversal( at android.view.ViewRootImpl$ at android.view.Choreographer$ at android.view.Choreographer.doCallbacks( at android.view.Choreographer.doFrame( at android.view.Choreographer$ at android.os.Handler.handleCallback( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at at java.lang.reflect.Method.invokeNative( at java.lang.reflect.Method.invoke( at$ at at dalvik.system.NativeStart.main(

Afaik, I believe this is related to banners and not interstitial and I have no idea why it is happening.

Thank you in advance!


Hey LowlevelStudios,

Apologies for the late reply here. If the issue is still occurring, please see below.

Per the crash report, there seems to be an Illegal state error when checkState(boolean expression) is called in Preconditions.

The illegal state is a result of getRootView.

This leads me to believe that the MRAID ad is being called before the container is ready, throwing the exception and causing the crash.

Could you provide more context as to how this crash is occurring and the setup you have?

  1. What MoPub SDK version are you using?
  2. Can you isolate it to either your banner or interstitial?
  3. What ad unit is this occurring under?
  4. Is this happening with a third party ad source or Marketplace?
  5. Do you know how to reproduce the crash (e.g. just open the app, minimize the app and re-open the app, etc.)? Please provide detail here, so we can reproduce the issue if possible.
  6. Is this happening on our sample app with the same ad unit?

Feel free to answer these questions by emailing referencing this forum post as there is required information tied to your account (ad unit).

If you have any further questions or need any clarifications in the meantime, please reach out. We would be happy to assist.