我正在通过Android Studio运行react-native应用程序,并且我一直遇到android支持依赖项的构建错误。我通过Android Studio安装了必要的SDK平台和工具,但我仍然遇到此错误。
Could not find com.android.support:support-v7:26.0.2.
起初我使用的是 27.0.3,但后来我注意到我的所有库都默认为 26.0.2,如构建过程中的以下警告消息所述 - The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
我咨询了各种StackOverflow解决方案,每次构建都失败。关于我可能做错了什么的任何想法?
app/build.gradle
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.jast"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-fetch-blob')
compile project(':react-native-aws')
compile project(':react-native-image-picker')
compile project(':react-native-mail')
compile project(':react-native-rate')
compile project(':appcenter-crashes')
compile project(':appcenter-analytics')
compile project(':appcenter')
compile project(':react-native-fcm')
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-maps')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:26.0.2"
compile "com.android.support:support-v7:26.0.2"
compile "com.facebook.react:react-native:+" // From node_modules
}
检查代码中的以下条件。
- 检查您的项目级别 build.gradle 中是否有
google()
。如果没有,请确保jcenter()
发生的位置google()
高于jcenter()
。 - 在应用级 build.gradle 中检查
gradle-wrapper.properties
是否具有与 appcompat 版本和 sdkdefaultConfig
version 相关的相应 gradle 版本
。
将项目级 gradle 依赖项更新到最新版本:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}