3

I want to create cool preferences activity. So I choose one of majority libraries from github (suppose this: https://github.com/codevscolor/MaterialPreference) But when I write dependency to my build.gradle I have warning about

"mixing libraries versions (found versions 25.3.1. and 23.4.0.) All libraries must have the exact same version specification"

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    testCompile 'junit:junit:4.12'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    //it's dependency for new great library
    compile 'com.codevscolor.materialpreference:mp:0.2.1'
}

Does there any way to avoid this errors?

Full build.gradle is here:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.parkfinder"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
    testCompile 'junit:junit:4.12'
    compile 'de.hdodenhof:circleimageview:1.3.0'
}
4

2 回答 2

1

Try adding

 compile 'com.android.support:preference-v7:25.3.1'

Update your build.gradle as

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:preference-v7:25.3.1'

compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'de.hdodenhof:circleimageview:1.3.0'
//it's dependency for new great library
compile 'com.codevscolor.materialpreference:mp:0.2.1'
}
于 2017-10-15T17:33:29.993 回答
0

That happens because the library com.codevscolor.materialpreference:mp:0.2.1 is using the version 25.4.0 of the support libraries. You have to upgrade your support libraries from 25.3.1 to 25.4.0 in order to use that dependency.

So, in your case:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    // Upgrade the support dependencies to 25.4.0
    compile 'com.android.support:appcompat-v7:25.4.0'
    compile 'com.android.support:support-v4:25.4.0'
    compile 'com.android.support:design:25.4.0'
    // Move it from alpha to the latest stable version.
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    //it's dependency for new great library
    compile 'com.codevscolor.materialpreference:mp:0.2.1'
}
于 2017-10-15T17:24:25.657 回答