Android 库必须使用相同的版本错误
每当我将Glide库添加到Android 库必须使用相同的版本错误,android,android-studio,build.gradle,android-support-library,Android,Android Studio,Build.gradle,Android Support Library,每当我将Glide库添加到app.gradle时,我都会遇到这个错误,我无法摆脱它 所有com.android.support库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。建立 版本27.1.1、26.1.0。例子包括 支持:support compat:27.1.1和 支持:动画矢量绘图:26.1.0以下。。。(Ctrl+F1) 有一些库或工具与库的组合 不兼容,或可能导致错误。这样的不相容性之一是 使用不兼容的Android支持库版本编译 最新版本(尤其是低于您的 targe
app.gradle
时,我都会遇到这个错误,我无法摆脱它
所有com.android.support库必须使用完全相同的版本
规范(混合版本可能导致运行时崩溃)。建立
版本27.1.1、26.1.0。例子包括
支持:support compat:27.1.1和
支持:动画矢量绘图:26.1.0以下。。。(Ctrl+F1)
有一些库或工具与库的组合
不兼容,或可能导致错误。这样的不相容性之一是
使用不兼容的Android支持库版本编译
最新版本(尤其是低于您的
targetSdkVersion。)
生成文件如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.david.six_month"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'commons-net:commons-net:3.6'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}
implementation ('com.github.bumptech.glide:glide:4.7.1', {
exclude group: 'com.android.support'
})
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
您需要有一个部分来定义配置,以强制执行需要使用的库的特定实现。比如说,
configurations.all {
resolutionStrategy {
force 'com.android.support:design:25.3.1'
force 'com.android.support:support-v4:25.3.1'
force 'com.android.support:appcompat-v7:25.3.1'
}
}
将此添加到您的项目级
build.gradle
文件中,它将强制所有android支持库使用相同的版本
allprojects {
...
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support') {
details.useVersion 'your library version here'
}
}
}
}
Glide似乎正在使用更新版本的支持库。您可以让其他支持库也使用最新版本,或者如果由于其他原因无法使用,请将支持库从Glide库中排除,如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.david.six_month"
minSdkVersion 15
multiDexEnabled true
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'commons-net:commons-net:3.6'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}
implementation ('com.github.bumptech.glide:glide:4.7.1', {
exclude group: 'com.android.support'
})
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
对于您的错误,例如: 所有com.android.support库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。建立 版本27.1.1、26.1.0。例子包括 支持:support compat:27.1.1和 支持:动画矢量绘图:26.1.0以下。。。(Ctrl+F1) *解决方案是编译这些库的版本,如下所示:
implementation 'com.android.support:animated-vector-drawable:27.1.1'
-如果另一个库有相同的问题,并且有另一个版本,只需使用您的支持进行编译:appcompat版本
这解决了我的问题,我希望也解决了你的问题
最好的祝愿:)我遇到了这个错误:
所有com.android.support库必须使用完全相同的版本
规范(混合版本可能导致运行时崩溃)。建立
版本27.1.1、26.1.0。例子包括
支持:动画矢量绘图:27.1.1和
支持:支持媒体兼容:26.1.0
然后我在build.gradle-Module:app
中添加了Design依赖项,解决了以下问题:
implementation 'com.android.support:design:27.1.1'
此错误是由于Glide库造成的。请尝试毕加索图像加载器或其他图像加载器这对我很有效。我正要把头撞到墙上。我所有的LIB都是26,除了最新的glide,我在gradle中得到了错误和混合支持LIB。