我正在开发一个新的react native项目,并使用了最新版本来支持AndroidX。当同时连接到iOS和Android的开发服务器时,我的应用程序在调试模式下可以正常运行。但是,当我尝试在Android上构建发行版APK时,它在模拟器和Android设备上都崩溃了。
当我运行adb logcat *:E
时,我将得到以下内容:
08-02 17:19:36.343 1437 1463 E SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
08-02 17:19:37.046 3919 3940 E ReactNativeJS: t is not a function. (In 't(c)', 't' is false)
--------- beginning of crash
08-02 17:19:37.056 3919 3941 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
08-02 17:19:37.056 3919 3941 E AndroidRuntime: Process: com.fitwaze, PID: 3919
08-02 17:19:37.056 3919 3941 E AndroidRuntime: com.facebook.react.common.JavascriptException: t is not a function. (In 't(c)', 't' is false), stack:
08-02 17:19:37.056 3919 3941 E AndroidRuntime: <unknown>@354:3111
08-02 17:19:37.056 3919 3941 E AndroidRuntime: map@-1
08-02 17:19:37.056 3919 3941 E AndroidRuntime: <unknown>@354:3090
08-02 17:19:37.056 3919 3941 E AndroidRuntime: <unknown>@371:312
08-02 17:19:37.056 3919 3941 E AndroidRuntime: v@2:1474
08-02 17:19:37.056 3919 3941 E AndroidRuntime: <unknown>@340:151
08-02 17:19:37.056 3919 3941 E AndroidRuntime: v@2:1474
08-02 17:19:37.056 3919 3941 E AndroidRuntime: <unknown>@6:58
08-02 17:19:37.056 3919 3941 E AndroidRuntime: v@2:1474
08-02 17:19:37.056 3919 3941 E AndroidRuntime: d@2:876
08-02 17:19:37.056 3919 3941 E AndroidRuntime: global code@830:4
08-02 17:19:37.056 3919 3941 E AndroidRuntime:
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:789)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:98)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
08-02 17:19:37.056 3919 3941 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
08-02 17:19:37.057 3919 3940 E ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)
这是我的 package.json 依赖项:
"dependencies": {
"formik": "^1.5.8",
"prop-types": "^15.7.2",
"react": "16.8.6",
"react-native": "0.60.4",
"react-native-gesture-handler": "^1.3.0",
"react-native-indicator": "^1.0.0",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-linear-gradient": "^2.5.5",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "^3.11.1",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-saga": "^1.0.5",
"yup": "^0.27.0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/runtime": "^7.5.0",
"@react-native-community/eslint-config": "^0.0.3",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.1.0",
"eslint": "^6.1.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.13.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.2",
"jest": "^24.1.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
感谢有人可以帮助您。 预先感谢。
答案 0 :(得分:0)
尝试运行以下代码:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
然后重新构建APK并检查它是否仍然崩溃了。