更新时间:2023-11-18 15:40:46
如果有人仍然在寻找这个,这是我根据Pritish对这个问题和类似问题的回答所做的。
In case anyone is still looking for this, here's what I did based on the answers from Pritish for this question and similar ones.
更新 android / gradle / wrapper / gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
更新 android / build.grad le classpath
Update android/build.gradle classpath
classpath 'com.android.tools.build:gradle:3.1.2'
更新 android / build.gradle (包括buildscript和所有项目)
Update android/build.gradle (both buildscript and allprojects)
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
...
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
如果您使用的是较早的react本地版本,则在更改之前要使用API 26,请在您的 android / app / build.gradle 文件中检查以下值:
If you are using an older react native version prior to the changes where they updated to use API 26, check these values in your android/app/build.gradle file:
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
...
targetSdkVersion 26
...
}