Android依赖冲突错误

标签 android dependencies

我尝试了很多小时来寻找解决方案,但找不到。我的问题是,当我构建 Gradle 时出现两个错误。我试着看看这个解决方案 Dependency conflict error in my Android app which has Android Tests但还是不能解决问题。

Error:Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.10) and test app (4.12) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

Error:Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

这是我的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
    applicationId "voice.com.topsalai"
    minSdkVersion 16
    targetSdkVersion 23
    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.3-
alpha', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

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

compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.android.support:support-annotations:26.0.0-alpha1'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.android.support:support-v4:23.1.1'
}

我该如何解决这个问题?

最佳答案

不要使用 alpha.. 或 beta.. 只使用最新的稳定版.. 然后请不要混合你的 android 支持版本.. 对所有 android 支持使用相同的版本示例

compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:cardview-v7:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:support-annotations:25.3.1"
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:support-v13:25.3.1"

关于Android依赖冲突错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43817004/

相关文章:

c++ - 如何以跨平台方式+CMake自动下载C++依赖?

android - BottomNavigationView + 在导航到不同选项卡时保存 fragment 状态

android - 使文本适合位图宽度

android - 工具栏中带有 windowActionBarOverlay 颜色的 DrawerArrowStyle

java - "One App"安卓系统

javascript - 单行注释会破坏 JavaScript 的执行

node.js - 将参数传递给nodejs中的子进程,该子进程在execFile方法中有一些依赖性

scala - SBT:列出项目依赖库

apache-spark - 了解 Spark 应用程序如何使用依赖项

c# - Visual Studio clean 解决方案不会删除所有被移动的 dll/项目引用