:app:compileDebugUnitTestJavaWithJavac 失败 Android Studio

:app:compileDebugUnitTestJavaWithJavac FAILED Android Studio

我已经在堆栈溢出等方面进行了很好的搜索,试图找到我的问题的答案。到目前为止,我一直无法找到适用于我的特定问题的任何解决方案。

直到 2 月 5 日,当我 运行 命令时:

.\gradlew test

命令将完成并且构建将成功。今天(7 日),我从我的团队远程仓库中提取了更改。当我 运行 命令时,我会得到以下输出:

:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComJourneyappsZxingAndroidEmbedded310Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:compileDebugUnitTestJavaWithJavac FAILED

BUILD FAILED

Total time: 5.804 secs

我创建了一个新的 b运行ch 以查看是否可以找出导致问题的提交,但是,当我检查一个我确定不包含问题的提交时(提交我以前去过)并尝试 运行 我会得到类似输出的命令。

同样,我以前只需右键单击我的测试文件,然后 select "Run whateverTest.java" 测试就会 运行.

现在,当我尝试同样的事情时,我得到以下输出:

!!! 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)
at com.intellij.rt.execution.junit.JUnitStarter.junitVersionChecks(JUnitStarter.java:191)
at com.intellij.rt.execution.junit.JUnitStarter.canWorkWithJUnitVersion(JUnitStarter.java:174)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

Process finished with exit code -3

现在我必须 select 文件和 运行 磁贴中的 select "Run..."。这将 运行 我的测试成功。

我尝试了通常的构建、干净重启计算机等。我还尝试创建一个 JAVA_HOME 和 ANDROID_JAVA_HOME 环境变量(在类似问题的推荐下)。

从那时起,唯一让我印象深刻的就是 java 更新。我怀疑这可能是原因,但我不确定。

如有任何帮助,我将不胜感激,如果需要,我可以提供更多详细信息。

谢谢。

更新

有关更多上下文,这里是 .\gradlew test

的更多输出
* What went wrong:
Execution failed for task ':app:compileDebugUnitTestJavaWithJavac'.
> Could not find tools.jar

希望这能提供更好的上下文。

已解决

问题已通过卸载 Java 和 Android Studio 然后重新安装解决。

我相信 Android Studio 中某处隐藏了一条我无法更改的路径,需要重新安装才能提示我进入 select。