Android 依赖性问题

Android 依赖性问题,android,android-preferences,gradle-dependencies,Android,Android Preferences,Gradle Dependencies,我想创建酷的首选项活动。因此,我从github中选择了一个大多数库(假设如下:) 但当我将依赖项写入build.gradle时,我有一个警告 “混合库版本(发现版本25.3.1.和23.4.0.)所有 库必须具有完全相同的版本规范“ 有没有办法避免这种错误 Full build.gradle在这里: apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "

我想创建酷的首选项活动。因此,我从github中选择了一个大多数库(假设如下:) 但当我将依赖项写入build.gradle时,我有一个警告

“混合库版本(发现版本25.3.1.和23.4.0.)所有 库必须具有完全相同的版本规范“

有没有办法避免这种错误

Full build.gradle在这里:

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'
}

这是因为库
com.codevscolor.materialpreference:mp:0.2.1
正在使用支持库的版本
25.4.0
。 您必须将支持库从
25.3.1
升级到
25.4.0
,才能使用该依赖项

因此,在你的情况下:

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'
}
尝试添加

 compile 'com.android.support:preference-v7:25.3.1'
将build.gradle更新为

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'
}

显示完整的
build.gradle
ok。我把它写在问题的最后,如果不起作用,试着清理一下你的项目。使缓存无效/重新启动。
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'
}