我在gradle文件中有一个错误用于编译'com.android.support:appcompat-v7:27.0.2'。

gradle版本是2.3.0

我搜索了很多,但无法解决此问题。
我的错误是:


  所有com.android.support库都必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本27.0.2、25.1.0、25.0.0。示例包括com.android.support:animated-vector-drawable:27.0.2和com.android.support:design:25.1.0


app/build.gradle

android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
    applicationId "com.example.pegah_system.sanduqchehproject"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
}
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.squareup.retrofit2:retrofit:2.0.0-beta4') {
    exclude module: 'okhttp'
}
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.github.ybq:Endless-RecyclerView:1.0.3'
compile 'com.github.ybq:Android-SpinKit:1.1.0'
compile 'com.github.qdxxxx:BezierViewPager:v1.0.5'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.roughike:bottom-bar:2.1.2'
compile 'com.squareup.okhttp3:okhttp:3.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:27.0.2'
testCompile 'junit:junit:4.12'
}

最佳答案

问题是因为项目中的依赖项冲突。您正在使用某些库,这些库隐式使用支持库27.0.225.1.025.0.0

以下库使用的支持库不同于27.0.2:

compile 'com.github.qdxxxx:BezierViewPager:v1.0.5'
compile 'com.roughike:bottom-bar:2.1.2'


BezierViewPager在其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.0.0'
    testCompile 'junit:junit:4.12'


    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
}


底部工具库在其build.gradlelibrary build.gradle中使用支持库25.0.2

ext {
    compileSdkVersion = 25
    buildToolsVersion = "25.0.2"
    minSdkVersion = 11
    targetSdkVersion = 25
    supportLibraryVersion = "25.3.0"

    junitVersion = "4.12"
}


因此,您需要从中排除支持库。您可以这样做:

  compile ("com.github.qdxxxx:BezierViewPager:v1.0.5") {
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
    exclude module: 'cardview-v7'
  }

  compile ("com.roughike:bottom-bar:2.1.2") {
    exclude group: 'com.android.support'
    exclude module: 'appcompat-v7'
    exclude module: 'design'
  }


如果仍然发现冲突的库,则可以检查依赖项树:

./gradlew app:dependencies

10-05 20:41
查看更多