主要是自己记录下,自己操作了以下几步才Ok
1.需要在app build.gradle导入依赖(这步好像并不能解决问题,因为解决了这个,还会出现其他androidx的报错)
dependencies {
implementation 'androidx.annotation:annotation:+'
}2.gradle.properties 中添加
android.useAndroidX = true
android.enableJetifier = true3.安装jetifier,找到RN项目的根目录,敲入下面命令行。可以参考这篇文章https://github.com/mikehardy/jetifier
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)
版权声明:本文为phenomenon123原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。