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

前端 未结 14 1418
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 15:50

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.r         


        
相关标签:
14条回答
  • 2021-01-07 16:30

    I was having the same error and I fixed it by updating JRE value under "Edit Configurations..." in Android Studio, I used API 28 instead and then it worked. Please check the image for your reference...

    0 讨论(0)
  • 2021-01-07 16:30

    To solve this issue, I set "JRE" to "1.8". This is Under "Edit Configurations"

    0 讨论(0)
  • 2021-01-07 16:36

    In my case I just forgot that I've changed the build variant to "release". Switching back to "debug" fixed everything. FML.

    0 讨论(0)
  • 2021-01-07 16:39

    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.

    0 讨论(0)
  • 2021-01-07 16:39

    This is apparently an Android Studio 4.1 issue. There's an open ticket for that already: https://issuetracker.google.com/issues/170328018

    What really solved the issue for me was reinstalling the Android 11 (API 30) SDK, according to the bug ticket above:

    "...there was an issue with API 30 mock jar that was built incorrectly. Can you open Android Studio SDK Manager and try uninstalling the R SDK or any Android SDK Platform 30 please? The Gradle build will auto install it when you try to rebuild after you delete the R SDK."

    0 讨论(0)
  • 2021-01-07 16:43

    If you have updated android studio version to 4.1 wiuth latest gradle plygin. Please comment out

    // useLibrary 'android.test.runner' It will fix error for you.

    0 讨论(0)
提交回复
热议问题