2

我迁移到较新的 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

根梯度

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:+'
}
4

2 回答 2

1

在我的情况下,我不得不关闭 gradle AndroidX 和 jettifier,因为一些库仍然依赖于旧的支持库,并且已经弃用了无法轻松迁移到 AndroidX 的依赖项。

于 2019-06-20T12:21:24.527 回答
0

那是因为您的 sdk 在更新到平台 28 时出现问题

打开安卓工作室

打开sdk管理器

勾选“显示包裹详情”

在package platform 28下,勾选“source for android”或类似的东西我不记得了,但它是package 28的源。点击ok下载它

重建检查

希望这有帮助

于 2019-06-19T17:48:05.580 回答