thundersdata-frontend / rn-template

雷数前端react native项目模版
Apache License 2.0
88 stars 35 forks source link

魅族手机切换导航方式再激活应用会卡住黑屏无响应 #27

Closed Atlan8 closed 2 years ago

Atlan8 commented 2 years ago

机型:魅族16th plus 系统版本:Flyme 8.1.5.1A 安卓版本:8.1.0

操作步骤:

  1. 使用 vscode 跑起应用
  2. 在手机打开应用后,按home键回到系统主页
  3. 前往系统设置将导航方式从 mBack 切换到 安卓导航栏
  4. 回到系统主页,再次打开应用
  5. 控制台就会出现报错信息,应用卡死黑屏无响应(如果没有出现就返回系统首页再次打开应用)

下面是控制台 log 的信息: LOG Skipping setJSExceptionHandler: Reason: In DEV mode and allowedInDevMode = false LOG Running "rnTemplate" with {"rootTag":1} LOG java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rntemplate/com.rntemplate.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment: calling Fragment constructor caused an exception at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2983) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3061) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4968) at android.app.ActivityThread.-wrap19(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1753) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:192) at android.app.ActivityThread.main(ActivityThread.java:6842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment: calling Fragment constructor caused an exception at androidx.fragment.app.Fragment.instantiate(Fragment.java:631) at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57) at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:483) at androidx.fragment.app.FragmentStateManager.(FragmentStateManager.java:85) at androidx.fragment.app.FragmentManager.restoreSaveState(FragmentManager.java:2728) at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:198) at androidx.fragment.app.FragmentActivity$2.onContextAvailable(FragmentActivity.java:149) at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.java:99) at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:297) at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:273) at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:45) at com.rntemplate.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:7065) at android.app.Activity.performCreate(Activity.java:7056) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1216) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931) ... 10 more Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at androidx.fragment.app.Fragment.instantiate(Fragment.java:613) ... 25 more Caused by: java.lang.IllegalStateException: Screen fragments should never be restored. Follow instructions from https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 to properly configure your main activity. at com.swmansion.rnscreens.ScreenFragment.(ScreenFragment.kt:42) ... 28 more

chj-damon commented 2 years ago

报错里面的这个解决办法你尝试了吗?

qqack commented 2 years ago

已经尝试解决了,可以试一下看看,我这边用魅族16th测试没有问题

Atlan8 commented 2 years ago

不好意思哈最近比较忙,我下午拉了代码,跑了一下发现没啥问题了,谢谢大佬