JUnit version 3.8 or later expected on android studio 4.1

1.5k views Asked by At

I have updated the Android studio to 4.1 and when I run JUnit I get below eorror

 !!! JUnit version 3.8 or later expected:

java.lang.RuntimeException: Stub!
    at junit.runner.BaseTestRunner.<init>(BaseTestRunner.java:14)
    at junit.textui.TestRunner.<init>(TestRunner.java:54)
    at junit.textui.TestRunner.<init>(TestRunner.java:48)
    at junit.textui.TestRunner.<init>(TestRunner.java:41)
    at com.intellij.rt.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:212)
    at com.intellij.rt.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:195)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:49)

Below is my configuration

JUnit Version: 4.12

Mockito Version: 3.5.11

PowerMockito Version: 2.0.7

Espresso Version: 3.3.0

Gradle Plugin version: 4.0.2 and 4.1.0

Gradle Version: 6.1.1 and 6.5

When I donwngradle to 4.0.2 it works fine

Please tell me what I am missing..

3

There are 3 answers

0
ant2009 On BEST ANSWER

I had the same issue when I upgrade to AS 4.1

I resolved this by removing the following from the build.gradle (app) file

useLibrary 'android.test.runner'

All tests run to completion

0
Neo Mn On

i faced this issue yesterday after updating my Ubuntu 20.04 LTS ,i was installed android studio from sanp store . finally managed to solve issue temporary , if you are in linux you have to find installed directory of android studio and inside bin directory , run studio.sh with sudo , it seems that it is a permission issue

sudo ./android-studioInstalledDirectory/bin/studio.sh
0
vonWippersnap On

I also faced this issue when I upgrade Android Studio to 4.1. Instead of removing the useLibrary line, I removed the testImplementation line I had before upgrading that brought in a version of JUnit explicitly.