我正在通过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
}
答案 0 :(得分:0)
检查代码中的以下条件。
google()
。如果不是,请确保jcenter()
发生的位置在google()
上方jcenter()
处。gradle-wrapper.properties
中defaultConfig
中是否具有与appcompat版本和sdkversion有关的gradle版本答案 1 :(得分:0)
将项目级别的gradle依赖关系更新为最新版本:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}