CLJSRN 发布构建运行时失败
CLJSRN Release Build Runtime Failure
我继承了这个 CLJS React Native 代码库,我正在尝试使用 React 16.4 和 RN 0.56 将 Android SDK 升级到 v26。调试版本运行良好,但发布版本在使用以下调用堆栈启动时失败:
2018-11-21 10:31:30.731 16727-16790/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: XXX, PID: 16727
com.facebook.react.common.JavascriptException: Can't find variable: a, stack:
<unknown>@12:60553
<unknown>@12:60366
<unknown>@12:518500
c@2:822
i@2:394
t@2:324
global code@322:8
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:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
关于如何获取调用堆栈的非缩小版本的任何想法?缩小是由 cljs 到 js 编译器完成的吗?或者 RN bundler/packager?
我目前正在 cljs 到 js 编译器上使用高级优化。如果我将其切换为空白优化,则会出现构建错误
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
我可以通过单独进行捆绑来解决这个问题
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/build/intermediates/assets/release/index.android.bundle --assets-dest /usr/src/app/android/app/build/intermediates/res/merged/release
但是我又打失败了
Unable to load script from assets 'index.android.bundle'.
还有什么我可以尝试的想法吗?
更新 1:"Unable to load script from assets 'index.android.bundle'." 错误消息是由 index.android.bundle 文件放置在错误的文件夹中引起的。以下命令有效:
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/src/main/assets/index.android.bundle --assets-dest /usr/src/app/android/app/src/main/res/
未缩小的调用堆栈如下所示:
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Exception: Can't find variable: document (index.android.bundle:1632)
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Stack: index.android.bundle:1632:43
loadModuleImplementation@index.android.bundle:162:14
guardedLoadModule@index.android.bundle:83:47
metroRequire@index.android.bundle:72:79
global code@index.android.bundle:1639:8
2018-11-27 15:07:00.749 23765-23859/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: XXX, PID: 23765
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
at com.facebook.react.bridge.CatalystInstanceImpl.access00(CatalystInstanceImpl.java:39)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.jni.CppException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
在我使用 react-native-git-upgrade 重新启动 RN 升级过程后,APK 工作正常。升级后出现了另一个问题,在运行时出现了一些未解析的符号,但事实证明这是 externs 文件的问题,因为我已经从已弃用的 BackAndroid 切换到 BackHandler。
我继承了这个 CLJS React Native 代码库,我正在尝试使用 React 16.4 和 RN 0.56 将 Android SDK 升级到 v26。调试版本运行良好,但发布版本在使用以下调用堆栈启动时失败:
2018-11-21 10:31:30.731 16727-16790/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: XXX, PID: 16727
com.facebook.react.common.JavascriptException: Can't find variable: a, stack:
<unknown>@12:60553
<unknown>@12:60366
<unknown>@12:518500
c@2:822
i@2:394
t@2:324
global code@322:8
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:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
关于如何获取调用堆栈的非缩小版本的任何想法?缩小是由 cljs 到 js 编译器完成的吗?或者 RN bundler/packager?
我目前正在 cljs 到 js 编译器上使用高级优化。如果我将其切换为空白优化,则会出现构建错误
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
我可以通过单独进行捆绑来解决这个问题
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/build/intermediates/assets/release/index.android.bundle --assets-dest /usr/src/app/android/app/build/intermediates/res/merged/release
但是我又打失败了
Unable to load script from assets 'index.android.bundle'.
还有什么我可以尝试的想法吗?
更新 1:"Unable to load script from assets 'index.android.bundle'." 错误消息是由 index.android.bundle 文件放置在错误的文件夹中引起的。以下命令有效:
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/src/main/assets/index.android.bundle --assets-dest /usr/src/app/android/app/src/main/res/
未缩小的调用堆栈如下所示:
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Exception: Can't find variable: document (index.android.bundle:1632)
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Stack: index.android.bundle:1632:43
loadModuleImplementation@index.android.bundle:162:14
guardedLoadModule@index.android.bundle:83:47
metroRequire@index.android.bundle:72:79
global code@index.android.bundle:1639:8
2018-11-27 15:07:00.749 23765-23859/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: XXX, PID: 23765
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
at com.facebook.react.bridge.CatalystInstanceImpl.access00(CatalystInstanceImpl.java:39)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.jni.CppException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
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:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
APK 工作正常。升级后出现了另一个问题,在运行时出现了一些未解析的符号,但事实证明这是 externs 文件的问题,因为我已经从已弃用的 BackAndroid 切换到 BackHandler。