Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'
  2. Cannot resolve symbol 'AndroidJUnit4'

To run integration tests in my Android Studio project. To solve this, I've seen some answers and my build.gradle looks like:

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'. Resolved versions for app (4.11) and test app (4.12) differ.

Thanks!

like image 631
Carlos Vázquez Losada Avatar asked Jan 04 '23 03:01

Carlos Vázquez Losada


1 Answers

One solution is to force Gradle to compile junit:junit:4.11 instead of junit:junit:4.12

To do that, in your app's build.gradle, add the following:

android {
    configurations.all {
        resolutionStrategy.force 'junit:junit:4.11'
    }
}
like image 116
Safwan Avatar answered Jan 14 '23 14:01

Safwan