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

前端 未结 14 1420
爱一瞬间的悲伤
爱一瞬间的悲伤 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:52

    I had to update a Gradle settings file according to these instructions. I just added the line

    testImplementation 'junit:junit:4.12'
    

    to the dependencies block of my app's build.gradle file. If you check the "Project" tab in Android studio (where you can see your source code files) there should be a "Gradle Scripts" section. Look for the build.gradle file named after your package and add that line to the dependencies block, then click the "Sync now" prompt that should come up.

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

    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.

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