問題描述
Android Studio + Gradle 新手.
New to Android Studio + Gradle.
我正在嘗試使用以下命令從命令行運行我的應用程序:
I'm trying to run my app from the command line using:
gradlew installDebug
只有當我剛剛打開 Studio 并執行初始同步/構建時執行該命令時,該應用才會安裝在我的設備上.
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.
每當我修改我的代碼并嘗試再次運行該命令時,構建都會失敗并顯示以下錯誤:
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
我該如何解決這個問題?提前致謝.
How do I solve this problem? Thanks in advance.
推薦答案
將 JAVA_HOME 變量設置為 C:Program FilesJavajdkX.XX 對我有用.
Setting the JAVA_HOME variable to C:Program FilesJavajdkX.XX worked for me.
由于某種原因,它以前被設置為 JRE 目錄.
It was previously set to the JRE directory for some reason.
這篇關于android - 任務':app:compileDebugJavaWithJavac'的執行失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!