react-native Android release打包失败的解决方案

本文解决了React Native 0.5x在使用Gradle 3.x版本进行安卓环境release编译时遇到的问题。通过调整Gradle配置文件,成功避免了资源处理和代码检查时出现的错误。

react-native 0.5x在安卓环境 gradle 3.x版本下编译release版本的时候提示编译失败,但是debug模式下是没有问题的。
笔者百度了很久,又去翻了翻谷歌,最后在GitHub的react-native的issue里面终于是找到了解决方案!下面先上一堆不同的错误信息好了

Could not find com.android.tools.lint:lint-gradle:26.1.1
Execution failed for task ‘:app:processReleaseResources’
Execution failed for task ‘:app:lintVitalRelease’

接下来是解决方案。
1. 在grade.properties 里添加 android.enableAapt2=false
2. 在build.gradle中添加 lintOptions { abortOnError false checkReleaseBuilds false }

值得一提的是 build.gradle 是在Android/app 下,而不是在Android下。

接下来配置好release的常规必要信息(什么jks之类的)就能够正常release了!congratulations~

D:\project\SmallProgram\myApp>yarn dev:rn yarn run v1.22.22 $ npm run build:rn -- --watch > myApp@1.0.0 build:rn > taro build --type rn --watch 👽 Taro v4.1.1 Tips: 预览模式生成的文件较大,设置 NODE_ENV 为 production 可以开启压缩。 Example: $ set NODE_ENV=production && taro build --type rn --watch Installing React-Native related packages: react@^18.2.0 react-dom@^18.2.0 react-native@^0.73.1 @react-native/metro-config@^0.73.2 expo@~50.0.2 @tarojs/taro-rn @tarojs/components-rn @tarojs/rn-runner @tarojs/rn-supporter @tarojs/runtime-rn React-Native related packages have been installed successfully. ATTEHNTION: Package.json has been modified automatically, please submit it by yourself. index.js created WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX has cached version (0.73.11) != current release (0.79.3) info Welcome to React Native v0.73 info Starting dev server on port 8081... To print qrcode press "q" Welcome to Metro v0.80.12 Fast - Scalable - Integrated info React Native v0.79.3 is now available (your project is running on v0.73.11). info Changelog: https://github.com/facebook/react-native/releases/tag/v0.79.3 info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.3 info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows". info Dev server ready i - run on iOS a - run on Android d - open Dev Menu r - reload app info Opening app on Android... info A dev server is already running for this project on port 8081.
最新发布
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值