ANDROID App crash when installed in device: JSException: Can't find variable: Promise (RN 0.57.1)

问题: Android app installs but crashes on open in devices, but in debug mode works perfectly. You can see the crash report below 2019-03-15 15:02:50.685 4431-4515/? E/WindowM...

问题:

Android app installs but crashes on open in devices, but in debug mode works perfectly.

You can see the crash report below

2019-03-15 15:02:50.685 4431-4515/? E/WindowManager: win=Window{8cd349a u0 Splash Screen com.sample EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0, caller=com.android.server.wm.AppWindowToken.destroySurfaces:748 com.android.server.wm.AppWindowToken.destroySurfaces:732 com.android.server.wm.WindowState.onExitAnimationDone:5646 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:553 com.android.server.wm.DisplayContent.lambda$-com_android_server_wm_DisplayContent_21578:476 
2019-03-15 15:02:51.555 970-1030/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.sample, PID: 970
com.facebook.react.common.JavascriptException: Can't find variable: props, stack:
value@285:1369
at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
    at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
    at android.os.Looper.loop(Looper.java:164)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
    at java.lang.Thread.run(Thread.java:764)
2019-03-15 15:02:51.989 4431-4515/? E/WindowManager: win=Window{bb689b5 u0 com.sample/com.sample.MainActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=false win.mRemoveOnExit=false win.mViewVisibility=8, caller=com.android.server.wm.AppWindowToken.destroySurfaces:748 com.android.server.wm.AppWindowToken.destroySurfaces:732 com.android.server.wm.WindowState.onExitAnimationDone:5646 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:553 com.android.server.wm.DisplayContent.lambda$-com_android_server_wm_DisplayContent_21578:476 

回答1:

Try to follow this issue: https://github.com/facebook/metro/issues/197:

When using react-native bundle (the command that runs when you build a release), InitializeCore.js is not the first file that get required, but instead it is required later, sometime during the generation of the bridge method, randomly (which is why if you are lucky or not using Promise // setTimeout early you'll be fine) iOS does not need all those polyfills which is why the issue is only detected on android in release mode.

  • 发表于 2019-03-17 19:31
  • 阅读 ( 3104 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除