1. 程式人生 > >安卓編譯錯誤app:compileDebugJavaWithJavac>Compilation failed; see the compiler error output for details.

安卓編譯錯誤app:compileDebugJavaWithJavac>Compilation failed; see the compiler error output for details.

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

編譯程式碼的時候出現了這種錯誤,於是在網上找了方法經過了多次試驗:
1,先嚐試在重新執行一兩遍試試。
2、檢查是否存在錯誤。
在命令列中進入專案的根目錄,或者可以在Android studio的Terminal中直接操作也可以,然後敲入一個命令:

gradlew compileDebug --stacktrace

3、Clean and Rebuild Project,然後執行一下看看
4、不行得話改一下build.gradle裡面的設定,Clean and Rebuild Project試一下

compileSdkVersion 23
buildToolsVersion "23.0.1"

//使用命令clean
gradlew clean

4、Android Studio 記憶體不夠用了,手動配置記憶體。
在as中檢視記憶體:
這裡寫圖片描述
右下角顯示記憶體
這裡寫圖片描述

gradle中配置

      dexOptions {
        javaMaxHeapSize "4g" 
        preDexLibraries = false
}

檔案中配置
找到Android的安裝包,開啟bin中的studio64.exe.vmoptions檔案notepad++開啟
這裡寫圖片描述
根據需求改大最上面兩個引數
這裡寫圖片描述
5、以上都不行的話,就要檢查自己的jdk的版本是否太低,更換一個最新的版本試試。