Search code examples
androidandroid-gradle-pluginbackwards-compatibility

Cannot resolve issue regarding backward compatibility library


I have Android Studio 3.1.2 Latest Updated .

I got an issue with Backward Compatibility as seen in image

Issue Image

Below is my gradle File

Gradle File :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.companyname.appname"
        minSdkVersion 21
        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.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    testCompile 'junit:junit:4.12'
    implementation 'com.android.support:multidex:1.0.1'
    implementation 'com.android.support:cardview-v7:27.1.1'

    implementation 'com.google.android.gms:play-services:9.2.0'
    implementation files('libs/ksoap2-android-assembly-2.4-jar-with-dependencies.jar')
    implementation('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }
    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'


}

The above is my gradle file , I am not using the library as described in Error , still getting error .


Solution

  • It's another library in your dependency list, which imports the noted support library. Because those library dependencies will clash, you have to add them explicitly. So you have to add the mediarouter-v7:27.1.1 to your dependencies and the message will go away. You will probably will have to add other dependencies too.

    This solution has a bitter taste, because you have to add dependencies, you don't actually need. You could try to find out which library actually uses the outdated version 23.0.0 and ask them to update the lib to a more recent version.

    Maybe it's this lib:

    implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
    

    It depends on

    compile 'com.android.support:appcompat-v7:23.1.1'
    

    So, as stated on their website you have to exclude those libs:

    If you have appcompat-v7 in your dependencies make sure to exclude it :

    compile ('com.weiwangcn.betterspinner:library:1.1.0') {
    exclude group: 'com.android.support', module: 'appcompat-v7' }
    

    UPDATE

    After I came along this issue again while working with Google Wear OS, it is helpful to show the dependency tree to track down, which dependency actually includes conflicting libraries:

    ./gradlew app:dependencies
    

    This prints you the full dependency graph, where you can see the corresponding sup-dependencies. Afterwards, you can exclude those from the lib which uses old references.