[英]Warning: Conflict with dependency 'junit:junit' in project ':app'. Resolved versions for app (4.11) and test app (4.12)
I'm trying to resolve two errors: 我正在尝试解决两个错误:
To run integration tests in my Android Studio project. 在我的Android Studio项目中运行集成测试。 To solve this, I've seen some answers and my build.gradle looks like:
为了解决这个问题,我已经看到了一些答案,我的build.gradle看起来像:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.ps.comunio.comuniops"
minSdkVersion 15
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'
}
debug {
debuggable true
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.11'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'info.cukes:cucumber-java:1.2.0'
compile 'info.cukes:cucumber-junit:1.2.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
}
This solve both errors, but a warning appears: 这样可以解决这两个错误,但会出现警告:
Error:Conflict with dependency 'junit:junit' in project ':app'.
错误:与项目':app'中的依赖项'junit:junit'冲突。 Resolved versions for app (4.11) and test app (4.12) differ.
app(4.11)和测试app(4.12)的已解决版本有所不同。
Thanks! 谢谢!
One solution is to force Gradle to compile junit:junit:4.11
instead of junit:junit:4.12
一种解决方案是强制Gradle编译
junit:junit:4.11
而不是junit:junit:4.12
To do that, in your app's build.gradle
, add the following: 为此,请在应用的
build.gradle
中添加以下内容:
android {
configurations.all {
resolutionStrategy.force 'junit:junit:4.11'
}
}
Remove 去掉
testCompile 'junit:junit:4.11'
with 同
compile 'junit:junit:4.11'
[replace testCompile with compile] [用编译替换testCompile]
With your problem you can try: 有了您的问题,您可以尝试:
file>>project Structure>>app>>dependencies>>click button "+" >>library dependence>>input junit>>click junit 4.12>>done
OK 好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.