我所有的依赖项都从版本 27 开始,但是构建任务仍然以异常结束:
Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.4.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:25.4.0 [GradleCompatible]
我知道我可以添加
lintOptions {
abortOnError false
}
它会解决我的问题,但我想找出原因。
这是我的 build.gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "my.company.app"
minSdkVersion 19
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "0.10.8"
vectorDrawables.useSupportLibrary = true
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://\"")
buildConfigField("String", "ENVIRONMENT", "\"release\"")
}
staging {
initWith debug
buildConfigField("String", "ENV_URL_PREFIX", "\"https://staging.\"")
buildConfigField("String", "ENVIRONMENT", "\"staging\"")
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://dev.\"")
buildConfigField("String", "ENVIRONMENT", "\"dev\"")
}
}
flavorDimensions "app"
productFlavors {
_Live {
dimension "app"
buildConfigField("String", "TYPE", "\"live\"")
}
_Test {
dimension "app"
buildConfigField("String", "TYPE", "\"test\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
exclude 'lib/x86_64/freebsd/libscrypt.so'
exclude 'lib/x86_64/linux/libscrypt.so'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.zxing:zxing-parent:3.3.3'
implementation 'com.google.zxing:core:3.3.2'
implementation 'com.google.guava:guava:22.0'
implementation project(':mobile_api') // a module compiled with java plugin
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
}
我的想法是某些依赖项通过 25.4.0 版传输 com.android.support 库。 如有任何建议,我将不胜感激。 提前致谢!
最佳答案
您正在使用这个库“com.crowdfire.cfalertdialog:cfalertdialog:1.1.0”, 它又使用 dependency 'com.android.support:cardview-v7:25.4.0' 也许这就是冲突的原因。
关于android - 混合版本会导致运行时崩溃。帮忙找个理由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51598153/