运行 flutter 应用程序执行任务失败 ':bluetoothadapter:compileDebugJavaWithJavac'

running flutter app got Execution failed for task ':bluetoothadapter:compileDebugJavaWithJavac'

我没有在我的 Flutter 应用程序中进行任何更改,它 运行 非常完美,但是当我在真实设备上尝试 运行 时,我遇到了这个异常 失败:构建失败,出现异常。

* What went wrong:
Execution failed for task ':bluetoothadapter:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_321 contains a valid JDK installation.
BUILD FAILED in 13s
Exception: Gradle task assembleDebug failed with exit code 1

查看此 post 解决方法:

tools.jar seems to be not in Android Studio classpath on Windows 8

似乎 tools.jar 不再出现在 Java 8 的每个版本中。还要确保使用 JDK 而不是纯 JRE 进行开发。

也许值得从 https://adoptopenjdk.net

下载 JDK 的当前版本