一、前言:
编译时直接报错“Error:org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.”
image.png
在 gradle 中查看详情时的错误,变成“Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.”
在 gradle 中查看错误具体原因如下图:
image.png
注意这一行
javacTask: 源发行版 1.8 需要目标发行版 1.8
二、解决方法:
1. 分析原因:
由于我在写 lamdba 表达时是,爆出“lambda expressions are not supported at this language level”这个错误
,所以更改了Source Compatibility的版本是 1.8 和Target Compatibility 的版本不一致,
如下图所示:
image.png
2. 具体解决:
修改 Source Compatibility 和Target Compatibility 必须选择版本一致即可。
如下图所示:
image.png
这样项目就可以正常运行了。