Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - with Junit 4.12 “!!! JUnit version 3.8 or later expected:”

Tried out the suggestions on this post, but I still get the error:

!!! JUnit version 3.8 or later expected:  java.lang.RuntimeException: Stub!     at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:5)     at junit.textui.TestRunner.<init>(TestRunner.java:54)     at junit.textui.TestRunner.<init>(TestRunner.java:48)     at junit.textui.TestRunner.<init>(TestRunner.java:41)  Process finished with exit code -3 

Not sure what to do from here. Tried reorganizing the order of the Junit dependency. No luck, anyone else get this issue?

Android Studio V. 1.2.1.1

like image 303
Timothy Frisch Avatar asked Jun 03 '15 19:06

Timothy Frisch


People also ask

Where is JUnit version in IntelliJ?

When you run JUnit from IntelliJ, the very first line of the console output displays your classpath. You can use Ctrl+F to find any "junit" references.

What is AndroidX test?

AndroidX Test is a collection of Jetpack libraries that lets you run tests against Android apps. It also provides a series of tools to help you write these tests. For example, AndroidX Test provides JUnit4 rules to start activities and interact with them in JUnit4 tests.


2 Answers

Solved the issue. I was running the JUnit tests as a standard "JUnit test" in Android Studio. I fixed the issue by resetting the configuration as a Android Test.

like image 101
Timothy Frisch Avatar answered Oct 18 '22 13:10

Timothy Frisch


Just to add one more situation. I was having this error after updating Android Studio to 4.1 on a project using old AGP (3.3.2) and Gradle (4.10.2). What ended up solving the issue for me was removing the android.test.runner library from gradle dependencies, that is removing the following line from the app's module build.gradle:

useLibrary 'android.test.runner' 

I probably got lucky to not actually need any of the classes provided by the library for unit or instrumented tests.

like image 37
ianribas Avatar answered Oct 18 '22 15:10

ianribas