简体   繁体   English

警告:与项目':app'中的依赖项'junit:junit'冲突。 app(4.11)和test app(4.12)的已解决版本

[英]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: 我正在尝试解决两个错误:

  1. Cannot resolve symbol 'test' 无法解析符号'test'
  2. Cannot resolve symbol 'AndroidJUnit4' 无法解析符号'AndroidJUnit4'

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.

相关问题 在项目':app'中与依赖'com.google.code.gson:gson'冲突。 app(2.7)和测试app(2.8.0)的已解决版本不同 - Conflict with dependency 'com.google.code.gson:gson' in project ':app'. Resolved versions for app (2.7) and test app (2.8.0) differ 与项目':app'中的依赖项冲突。 app(15.0.2)和测试app(12.0.1)的已解决版本不同(可能是信号和firebase问题) - Conflict with dependency in project ':app'. Resolved versions for app (15.0.2) and test app (12.0.1) differ (possibly onesignal&firebase issue) 错误:与项目':app'中的依赖项'com.android.support:support-v4'发生冲突。 应用(25.3.1)和测试应用(23.1.1)的已解决版本不同 - Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (25.3.1) and test app (23.1.1) differ 与项目':app'中的依赖'com.android.support:support-annotations'冲突。 app(26.1.0)和测试app(27.1.1)的已解决版本有所不同。 - Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. 错误:在项目':app'中与依赖项'com.google.guava:guava'发生冲突。 应用(18.0)和测试应用(16.0.1)的已解决版本不同 - Error:Conflict with dependency 'com.google.guava:guava' in project ':app'. Resolved versions for app (18.0) and test app (16.0.1) differ 错误:无法解析':app @ debugAndroidTest / compileClasspath'的依赖项:无法解析junit:junit:4.12 - Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve junit:junit:4.12 适用于Android应用程序的JUnit测试 - JUnit Test for Android app Espresso错误:与依赖项“ com.android.support:support-v4”发生冲突。 应用(24.2.0)和测试应用(23.1.1)的已解决版本不同 - Espresso Error:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (24.2.0) and test app (23.1.1) differ 与依赖'com.android.support:support-annotations'冲突。 app(23.3.0)和测试app(23.1.1)的已解决版本有所不同 - Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.3.0) and test app (23.1.1) differ 与依赖'com.android.support:support-annotations'冲突。 app(23.1.0)和测试app(23.0.1)的已解决版本有所不同 - Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM