Error:org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; 解決

一、前言:

編譯時(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)行了。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容