Maven 3 and JUnit 4 compilation problem: package org.junit does not exist

前端 未结 16 1545
时光取名叫无心
时光取名叫无心 2020-12-13 12:06

I am trying to build a simple Java project with Maven. In my pom-file I declare JUnit 4.8.2 as the only dependency. Still Maven insists on using JUnit version 3.8.1. How do

16条回答
  •  旧时难觅i
    2020-12-13 12:30

    Me too had the same problem as shown below.

    To resolve the issue, below lines are added to dependencies section in the app level build.gradle.

    compile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:runner:0.5'
    

    Gradle build then reported following warning.

    Warning:Conflict with dependency 'com.android.support:support-annotations'. 
    Resolved versions for app (25.1.0) and test app (23.1.1) differ. 
    See http://g.co/androidstudio/app-test-app-conflict for details.
    

    To solve this warning, following section is added to the app level build.gradle.

    configurations.all {
        resolutionStrategy {
            force 'com.android.support:support-annotations:23.1.1'
        }
    }
    

提交回复
热议问题