Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; ...

Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
如何查看具体异常呢?
命令 gradle compileDebugJavaWithJavac查看具体的异常所在

$ gradle  compileDebugJavaWithJavac

> Task :app:compileDebugJavaWithJavac FAILED
javacTask: 源发行版 1.8 需要目标发行版 1.8


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
15 actionable tasks: 1 executed, 14 up-to-date

javacTask: 源发行版 1.8 需要目标发行版 1.8这句提示我们JDK版本导致的问题
右击项目,点击如下图选项’Open Module Setting’

《Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; ...》 Open Module Setting

JDK版本号一致即可

《Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; ...》 JDK统一版本号

    原文作者:IT枫
    原文地址: https://www.jianshu.com/p/0ce6166aefc3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞