Android依赖冲突错误 [英] Android dependency conflict error

查看:78
本文介绍了Android依赖冲突错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了许多小时才能找到解决方案,但找不到。我的问题是,在构建Gradle时出现两个错误。我试图查看此解决方案
我的具有Android测试功能的Android应用中的依赖项冲突错误,但仍然无法解决问题。

I tried for many hours to find the solution but could not find. My problem is that when I build my Gradle I get two errors. I tried to look at this solution Dependency conflict error in my Android app which has Android Tests but could still not solve the problem.

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

Here's my 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'
}

我该如何解决?

推荐答案

我找到了解决方案。通过将compileSdkVersion升级到

I found the solution. By upgrading compileSdkVersion to

compileSdkVersion 25 

然后代替这个

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

仅通过更新appcompat-v7:23.1.1并不能解决问题。我需要这些3行代码。

Only by updating appcompat-v7:23.1.1 did not solve it. I needed theese 3 lines of code.

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'

这篇关于Android依赖冲突错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆