通常在Android Studio
編譯中,經(jīng)常會出現(xiàn)一些錯誤,提示信息大概是類似"xxxx,see the compiler error output for details.",我們從中得不到比較有效的信息。
在Terminal
中輸入以下命令,可以得到更為有效的編譯信息:
gradlew compileDebug --stacktrace
如果想得到更詳細的信息,可以在以上命令后面增加-info
或'-debug'比如gradlew compileDebug --stacktrace -info
或者嘗試gradlew compileDebugSources --stacktrace -info
命令
參考資料:https://blog.csdn.net/runner__1/article/details/53482565
關于Mac下`gradlew: command not found
引起原因:gradlew不在系統(tǒng)全局變量路徑中,當執(zhí)行命令時會報錯,提示找不到。
解決辦法1:
因為沒有在全局變量路徑中設置gradlew,所以找不到gradlew命令,那么我們可以使用gradlew的絕對路徑來使用命令:{絕對路徑}/gradlew {cmd}..
,比如{絕對路徑}/gradlew compileDebug --stacktrace -info
;
gradlew的絕對路徑通常是在Android工程的根目錄下。因此在Android Studio的Terminal中使用gradlew命令,則可以使用./指定當前目錄,即./gradlew {cmd}
的形式,比如./gradlew compileDebug --stacktrace -info
;
解決辦法2:
配置全局環(huán)境變量
找到gradle文件所在路徑。該文件可在Android Studio安裝目錄下找到,如:/Applications/Android Studio.app/Contents/gradle/gradle-2.14.1/bin
配置.bash_profile文件。
在文件中添加如下內(nèi)容:export PATH=${PATH}:/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin
注意AndroidStudio單詞間的 \ + 空格。使.bash_profile文件立刻生效。在終端執(zhí)行:source .bash_profile
資料參考:https://blog.csdn.net/lvxiangan/article/details/70844264