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

3. React Native v0.49 构建打包相关文档链接:

https://github.com/reactnativecn/react-native-website/blob/production/archived_docs/version-0.49/android-building-from-source.md

4. 打包64位:

https://blog.csdn.net/Hansen_0320/article/details/100893270

posted @   djzz  阅读(217)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示