更新时间:2022-11-26 10:40:15
确保运行测试的设备已解锁.如果屏幕关闭或处于锁定屏幕,您将获得一个大致如下所示的堆栈跟踪:
Make sure the device you are running the tests on is unlocked. If the screen is off or at the lock screen you will get a stack trace that looks roughly like this:
java.lang.RuntimeException: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.test.runner.MonitoringInstrumentation.runOnMainSync(MonitoringInstrumentation.java:441)
at androidx.test.core.app.ActivityScenario.onActivity(ActivityScenario.java:564)
at androidx.fragment.app.testing.FragmentScenario.internalLaunch(FragmentScenario.java:300)
at androidx.fragment.app.testing.FragmentScenario.launchInContainer(FragmentScenario.java:282)
at com.foo.package.YourFragmentTest.yourTestFunction(YourFragmentTest.kt:xy)
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
java.lang.IllegalStateException:由launchFragmentInContainer引起的onSaveInstanceState之后无法执行此操作
提交结果失败ResultInfo | java.lang.IllegalStateException:在onSaveInstanceState之后无法执行此操作
java.lang.IllegalStateException(在onSaveInstanceState之后无法执行此操作)
异常java.lang.IllegalStateException:在onSaveInstanceState之后无法执行此操作
原因:java.lang.IllegalStateException:onSaveInstanceState之后无法执行此操作
java.lang.IllegalStateException: 在 onSaveInstanceState 之后无法执行此操作
java.lang.IllegalStateException: 在 onSaveInstanceState 和 DialogFragment 之后无法执行此操作