React Native旧项目 打包错误&解决方法记录
最近一个n年前的RN项目需要重新打包,遇到很多问题,在这里记录一下。
旧项目的相关依赖包版本:
"react": "16.0.0-beta.5",
"react-native": "0.49.3",
"react-native-device-info": "^0.17.4",
环境配置相关:
// 低于 0.67 版本的 React Native 需要 JDK 1.8 版本(官方也称 8 版本)。
JDK openjdk version "1.8.0_42"
NDK android-ndk-r10e
node 10.24.1
npm 6.14.12
错误问题 & 解决方法记录
1. ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
解决方法:
https://github.com/react-native-device-info/react-native-device-info/issues/694
将此代码添加到您的项目android/build.gradle,解决了
ext {
buildToolsVersion ="23.0.1"
minSdkVersion = 16
compileSdkVersion = 23
targetSdkVersion = 23
supportLibVersion ="23.0.0"
googlePlayServicesVersion ="15.0.1" //重点是这句
}
2. 程序包com.facebook.react不存在
问题1中 修改了 googlePlayServicesVersion,会出现问题2,
解决方法:
在项目下的 android/build.gradle 文件中添加如下代码,即可成功编译
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}
3. Unable to process incoming event 'ProgressComplete ' (ProgressCompleteEvent)
解决方法:
打包时使用以下命令
./gradlew assembleRelease --console plain //我是这条命令解决的
或者
./gradlew assembleRelease –-stacktrace
其他
1. Apk转Aab(Android App Bundle)
https://www.jianshu.com/p/117ebe7c6fd5
2. Aab(Android App Bundle)测试与安装
https://www.jianshu.com/p/a580f87e9df5
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示