IntelliJ IDEA with Junit 4.7 "!!! JUnit version 3.8 or later expected:" IntelliJ IDEA with Junit 4.7 "!!! JUnit version 3.8 or later expected:" android android

IntelliJ IDEA with Junit 4.7 "!!! JUnit version 3.8 or later expected:"


This problem happens because Android Platform (android.jar) already contains JUnit classes. IDEA test runner loads these classes and sees that they are from the old JUnit, while you are trying to use annotated tests which is a feature of the new JUnit, therefore you get the error from the test runner.

The solution is simple, open the Project Structure | Modules | Dependencies, and move the junit-4.7.jar up, so that it comes before Android 1.6 Platform in the classpath. Now the test runner will be happy as it loads the new JUnit version.


enter image description here

my module is a java library module, so changing JRE to 1.8 java solved the issue.

Or, you can also do it globally via Module Settings > SDK Location > JDK, specifying Oracle's JDK 8 instead of Android SDK's copy.


I had this problem with a multi module project (libgdx). One module is pure Java and has tests.My solution was to set "use alternative JRE" to "Java 1.8" in the run configuration of my unit tests. This makes sure no android.jar is on the classpath and the junit 4.x runner is used.