-
执行
./gradlew assembleRelease
报出Unable to resolve module AccessibilityInfo
错误
打release包失败,项目配置文件如下,React Native 版本号为0.56.0
"dependencies": {
"react": "16.4.1",
"react-native": "^0.56.0"
},
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "5",
"jest": "23.5.0",
"react-test-renderer": "16.4.1"
},
错误原因:这是React Native0.56.0
最新版本的携带的错误,问题只会发生在Windows操作系统,mac不会。
解决方法:修改packjosn
配置文件,降低到稳定版本
"dependencies": {
"react": "^16.4.1",
"react-native": "^0.55.4"
},
"devDependencies": {
"babel-preset-react-native": "^4.0.0",
},
然后依次执行cmd命令
npm update
npm cache clean --force
cd android
gradlew clean
cd..
react-native run-android
-
React Native Release包启动闪退,报出
Unable to load script from assets 'index.android.bundle'
错误
issue截图:
image.png
错误信息:
AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: com.awesomeproject, PID: 3218
java.lang.RuntimeException: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged correctly or you're running a packager server.
at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:216)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:31)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:234)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1114)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:911)
at java.lang.Thread.run(Thread.java:761)
错误原因:找不到android/app/src/main/assets/index.android.bundle
文件
解决方法:每次编译打包之前需要先执行 js 文件的打包(即生成离线的 jsbundle 文件)。具体的 js 打包命令如下:
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/
如果 assets 目录不存在,则需要提前自己创建一个。
未完待续,持续更新~~~~~
网友评论