Не удалось разрешить зависимость в Gradle

У меня проблема с классом для библиотеки

implementation 'com.android.support:appcompat-v7:27.1.1'

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.2.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:support-media-compat:25.2.0 less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

Мой файл gradle содержит следующий код.

Моя Android Studio работает на Android Studio 3.1

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "greetgalleryfree.binarycrust.com"
        minSdkVersion 18
        targetSdkVersion 27
        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:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    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'
}

apply plugin: 'com.google.gms.google-services'

В терминале IDE введите «gradlew app: dependencies» и посмотрите, куда втягивается 25.2.0. Это длинный вывод, поэтому при необходимости перенаправляйте его в выходной файл.

Andy 08.04.2018 21:42
2
1
341
1

Ответы 1

Добавьте это в самый конец вашего build.gradle (Module: app):

resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '27.1.1'
        }
     }

   }
}

Убедитесь, что вы заменили '27 .1.1 'версией библиотеки поддержки Android, которую вы хотите использовать для всех зависимостей, она не должна быть ниже, чем ваша совместимая версия sdk.

чем повторно синхронизировать градиент

Другие вопросы по теме