問題描述
Android Studio + Gradle 新手.
New to Android Studio + Gradle.
我正在嘗試使用以下命令從命令行運(yùn)行我的應(yīng)用程序:
I'm trying to run my app from the command line using:
gradlew installDebug
只有當(dāng)我剛剛打開 Studio 并執(zhí)行初始同步/構(gòu)建時(shí)執(zhí)行該命令時(shí),該應(yīng)用才會安裝在我的設(shè)備上.
The app gets installed on my device only when I execute that command when Studio just got opened and do that initial syncing/building thing.
每當(dāng)我修改我的代碼并嘗試再次運(yùn)行該命令時(shí),構(gòu)建都會失敗并顯示以下錯(cuò)誤:
Whenever I modified my code, and try to run that command again, the build fails and shows this error:
Execution failed for task ':app:compileDebugJavaWithJavac'
> Could not find tools.jar
我該如何解決這個(gè)問題?提前致謝.
How do I solve this problem? Thanks in advance.
推薦答案
將 JAVA_HOME 變量設(shè)置為 C:Program FilesJavajdkX.XX 對我有用.
Setting the JAVA_HOME variable to C:Program FilesJavajdkX.XX worked for me.
由于某種原因,它以前被設(shè)置為 JRE 目錄.
It was previously set to the JRE directory for some reason.
這篇關(guān)于android - 任務(wù)':app:compileDebugJavaWithJavac'的執(zhí)行失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!