一、前言:
編譯時(shí)直接報(bào)錯(cuò)“Error:org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.”

image.png
在 gradle 中查看詳情時(shí)的錯(cuò)誤,變成“Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.”
在 gradle 中查看錯(cuò)誤具體原因如下圖:

image.png
注意這一行
javacTask: 源發(fā)行版 1.8 需要目標(biāo)發(fā)行版 1.8
二、解決方法:
1. 分析原因:
由于我在寫 lamdba 表達(dá)時(shí)是,爆出“l(fā)ambda expressions are not supported at this language level”這個(gè)錯(cuò)誤
,所以更改了Source Compatibility的版本是 1.8 和Target Compatibility 的版本不一致,
如下圖所示:

image.png
2. 具體解決:
修改 Source Compatibility 和Target Compatibility 必須選擇版本一致即可。
如下圖所示:

image.png
這樣項(xiàng)目就可以正常運(yùn)行了。