依赖性问题
Problems with dependencies
我想创建很酷的首选项activity。所以我从 github 中选择了大多数库之一(假设是这样的:https://github.com/codevscolor/MaterialPreference)
但是当我将依赖项写入 build.gradle 时,我收到了关于
的警告
"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'
}
有什么办法可以避免这个错误吗?
完整 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'
}
我想创建很酷的首选项activity。所以我从 github 中选择了大多数库之一(假设是这样的:https://github.com/codevscolor/MaterialPreference) 但是当我将依赖项写入 build.gradle 时,我收到了关于
的警告"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'
}
有什么办法可以避免这个错误吗?
完整 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'
}