我迁移到了较新的React Native,并将一些库更新为最新版本。一块我的project.json
:
"@react-native-community/async-storage": "^1.4.1",
"@react-native-community/netinfo": "^3.1.1",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-preset-react-native": "^4.0.0",
"react": "16.8.6",
"react-native": "^0.59.8"
我在这里遇到这个问题:
D:\ myapp \ node_modules @ react-native-community \ netinfo \ android \ src \ main \ java \ com \ reactnativecommunity \ netinfo \ ConnectivityReceiver.java:12: 错误:包android.support.v4.net不存在导入 android.support.v4.net.ConnectivityManagerCompat; ^ D:\ myapp \ node_modules @ react-native-community \ netinfo \ android \ src \ main \ java \ com \ reactnativecommunity \ netinfo \ ConnectivityReceiver.java:154: 错误:找不到符号 ConnectivityManagerCompat.isActiveNetworkMetered(getConnectivityManager()); ^符号:变量ConnectivityManagerCompat位置:类ConnectivityReceiver 2错误
gradle.properties
android.enableJetifier = true
android.useAndroidX=true
root gradle
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion="28.0.0"
}
渐变依赖项
dependencies {
implementation project(':react-native-code-push')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-webview')
implementation project(':react-native-push-notification')
implementation project(':@react-native-community_netinfo')
implementation project(':@react-native-community_async-storage')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.google.firebase:firebase-messaging:+'
implementation 'com.facebook.react:react-native:+'
}
答案 0 :(得分:0)
那是因为您的SDK在更新到平台28时出现问题
打开android studio
打开SDK管理器
选中“显示软件包详细信息”
在程序包平台28下,勾选“ android的源代码”或我不记得的类似内容,但这是程序包28的源代码。单击“确定”下载它
重建以检查
希望获得帮助
答案 1 :(得分:0)
在我的情况下,我不得不关闭gradle AndroidX和jettifier,因为某些库仍然依赖于旧的支持库,并且已弃用了无法轻松迁移到AndroidX的依赖。