活动因“ java.lang.IllegalStateException”而崩溃

时间:2018-11-19 08:22:13

标签: android android-fragments android-viewpager

我开发了一款Kotlin应用程序,并测试了它在所有经过测试的设备上都可以正常运行后,将其发布在Playstore上,但是在Play控制台上,我收到了这个错误,但我无奈地从任何地方查找此错误的原因我认为OS 8.0中存在错误,因为Android 8.0中存在99%的错误 请帮助我摆脱它

java.lang.IllegalStateException:
at android.support.v4.app.FragmentManagerImpl.saveAllState (FragmentManager.java:2960)
at android.support.v4.app.FragmentController.saveAllState (FragmentController.java:134)
at android.support.v4.app.FragmentActivity.onSaveInstanceState (FragmentActivity.java:591)
at android.support.v7.app.AppCompatActivity.onSaveInstanceState (AppCompatActivity.java:510)
at android.app.Activity.performSaveInstanceState (Activity.java:1487)
at android.app.Instrumentation.callActivityOnSaveInstanceState (Instrumentation.java:1318)
at android.app.ActivityThread.callCallActivityOnSaveInstanceState (ActivityThread.java:5489)
at android.app.ActivityThread.performStopActivityInner (ActivityThread.java:4777)
at android.app.ActivityThread.handleStopActivity (ActivityThread.java:4851)
at android.app.ActivityThread.access$1400 (ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1850)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:7406)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)

我尝试了几件事,但没有任何帮助,只有在测试期间才从Play控制台收到

我的代码没有任何崩溃。

编辑

我的MainTabbedActivity的onCreate方法中发生了另一个相关的错误

java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3256)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3352)
at android.app.ActivityThread.access$1100 (ActivityThread.java:223)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1797)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7231)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException:
at android.support.v4.app.FragmentManagerImpl.restoreAllState (FragmentManager.java:3142)
at android.support.v4.app.FragmentController.restoreAllState (FragmentController.java:158)
at android.support.v4.app.FragmentActivity.onCreate (FragmentActivity.java:344)
at android.support.v7.app.AppCompatActivity.onCreate (AppCompatActivity.java:85)
at com.gpstrack.mapsnavigation.location.ui.view.MainTabbedActivity.onCreate (MainTabbedActivity.kt:68)
at android.app.Activity.performCreate (Activity.java:6877)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3209)

1 个答案:

答案 0 :(得分:1)

经过过多的更新,实验和大量的崩溃后,我找到了针对该崩溃的解决方案,该解决方案来自AdMob AdActivity,当设备更改其方向时会产生问题,因此我在AndroidManifest.xml中添加了以下几行:

<activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        tools:replace="android:theme" />
  

问题已解决,我的应用现已免费崩溃