Android-зависимость имеет разную версию для компиляции и времени выполнения
После обновления Android Studio от Канарейки 3 до Канарейки 4 следующая ошибка возникает во время сборки.
Android-зависимость "com.android.support:support-support-v4" имеет другую версию для пути к компиляции (25.2.0) и runtime (26.0.0-beta2). Вы должны вручную установить ту же версию через DependencyResolution.
Я выполнил полный поиск по всему проекту, а версия 25.1.0
здесь не используется.
App-build.gradle
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.xxx.xxxx"
minSdkVersion 14
targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
lintOptions {
abortOnError false
}
}}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation project(':core')
implementation com.google.android.gms:play-services-gcm:9.0.0'
implementation('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true
}
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.flurry.android:analytics:7.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
implementation 'com.jakewharton:butterknife:8.6.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
Library-build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation files('libs/model.jar')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:percent:26.0.0-beta2'
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
implementation 'com.android.support:support-core-utils:26.0.0-beta2'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.squareup.picasso:picasso:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.2.0'
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'com.android.support:design:26.0.0-beta2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
Примечание: Проект строился в Canary 3
Ответы
Ответ 1
Используйте этот код в вашем buildscript (build.gradle root):
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "version which should be used - in your case 26.0.0-beta2"
}
}
}
}
Ответ 2
У меня была такая же ошибка, что и моя проблема. В моей библиотеке вместо использования компиляции или реализации я использую "api". Поэтому в конце мои зависимости:
dependencies {
api fileTree(dir: 'libs', include: ['*.jar'])
api files('libs/model.jar')
testApi 'junit:junit:4.12'
api 'com.android.support:percent:26.0.0-beta2'
api 'com.android.support:appcompat-v7:26.0.0-beta2'
api 'com.android.support:support-core-utils:26.0.0-beta2'
api 'com.squareup.retrofit2:retrofit:2.0.2'
api 'com.squareup.picasso:picasso:2.4.0'
api 'com.squareup.retrofit2:converter-gson:2.0.2'
api 'com.squareup.okhttp3:logging-interceptor:3.2.0'
api 'uk.co.chrisjenx:calligraphy:2.2.0'
api 'com.google.code.gson:gson:2.2.4'
api 'com.android.support:design:26.0.0-beta2'
api 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
Более подробную информацию о "api", "реализация" можно найти в этой ссылке fooobar.com/questions/23377/...
Ответ 3
Вы должны быть в состоянии точно увидеть, какая зависимость gradle -q dependencies
нечетную версию в качестве транзитивной зависимости, запустив правильную gradle -q dependencies
для вашего проекта, как описано здесь:
https://docs.gradle.org/current/userguide/userguide_single.html#sec:listing_dependencies
После того, как вы отследите, что в него входит, вы можете добавить исключение к этой конкретной зависимости в файле Gradle с помощью чего-то вроде:
implementation("XXXXX") {
exclude group: 'com.android.support', module: 'support-compat'
}
Ответ 4
После большого количества времени и получения помощи от друга, который знает об андроиде намного больше меня: app/build.gradle
android {
compileSdkVersion 27
// org.gradle.caching = true
defaultConfig {
applicationId "com.cryptoviewer"
minSdkVersion 16
targetSdkVersion 23
versionCode 196
versionName "16.83"
// ndk {
// abiFilters "armeabi-v7a", "x86"
// }
}
и зависимости
dependencies {
implementation project(':react-native-camera')
//...
implementation "com.android.support:appcompat-v7:26.1.0" // <= YOU CARE ABOUT THIS
implementation "com.facebook.react:react-native:+" // From node_modules
}
в build.gradle
allprojects {
//...
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:26.1.0"
}
в gradle.properties
android.useDeprecatedNdk=true
android.enableAapt2=false
org.gradle.jvmargs=-Xmx4608M
Ответ 5
Для меня ответ был также добавить это в мой файл build.gradle
:
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
В моем случае было необходимо заключить стратегию разрешения в блок configurations.all {.. }
. Я поместил блок configurations.all
непосредственно в мой файл app/build.gradle
(то есть, файл configurations.all
не был вложен ни во что другое)
Ответ 6
Это сработало для меня:
Добавьте следующую строку в app/build.gradle
в разделе зависимостей:
implementation "com.android.support:appcompat-v7:27.1.0"
или :27.1.1
в моем случае
Ответ 7
Я решил это, следуя тому, что Эдди упомянул выше,
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
Ответ 8
Переключение моих конфликтующих зависимостей с реализации на API делает свое дело. Вот хорошая статья от mindorks, объясняющая разницу.
https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa
Редактировать:
Здесь мои разрешения зависимостей, а также
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "28.0.0"
}
if (details.requested.group == 'com.google.android.gms'
&& details.requested.name.contains('play-services-base')) {
details.useVersion "15.0.1"
}
if (details.requested.group == 'com.google.android.gms'
&& details.requested.name.contains('play-services-tasks')) {
details.useVersion "15.0.1"
}
}
}
}
Ответ 9
Посмотрите в своих проектах библиотеки сделать версию compileSdkVersion и targetSdkVersion на том же уровне, что и ваше приложение
android {
compileSdkVersion 28
defaultConfig {
consumerProguardFiles 'proguard-rules.txt'
minSdkVersion 14
targetSdkVersion 28
}
}
также сделать все зависимости на одном уровне
Ответ 10
Если кто-то получит эту проблему зависимости в 2019 году, обновите Android Studio до версии 3.4 или новее
Ответ 11
Я закомментирую //api 'com.google.android.gms:play-services-ads:15.0.1'
у меня это сработало после синхронизации
Ответ 12
Просто добавьте эти строки в ваш файл build.gradle
resolutionStrategy.force "com.android.support:support-media-compat:26.0.0-beta2"
resolutionStrategy.force "com.android.support:support-v4:26.0.0-beta2"
Ответ 13
Я решил эту проблему, обновив мою зависимость gradle в файле android/build.gradle: classpath 'com.android.tools.build:gradle:3.3.1' (ранее я работал над версией 3.2.
Ответ 14
Добавьте этот код в файл build.gradle уровня проекта.
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "version which should be used - in your case 28.0.0-beta2"
}
}
}
}
Пример кода:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'io.fabric.tools:gradle:1.31.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "28.0.0"
}
}
}
}
Ответ 15
Замените версию с жестким кодом на + пример:
implementation 'com.google.android.gms:play-services-base:+'
implementation 'com.google.android.gms:play-services-maps:+'