简体   繁体   English

Android Studio不执行build.gradle

[英]Android Studio doesn't execute build.gradle

If I add println("hello world!") to the build.gradle (the one in the root directory) in android studio, and execute gradlew from the command-line, I get "hello world!". 如果我将println("hello world!")到android studio中的build.gradle (根目录中的那个),然后从命令行执行gradlew ,我将得到“ hello world!”。 However, clicking the green arrow in the IDE does not result in this being printed. 但是,单击IDE中的绿色箭头不会导致此打印。 Also, if I do something like generate a text file, executing gradlew will also generate the text file. 另外,如果我执行类似生成文本文件的操作,则执行gradlew也会生成文本文件。

I'm trying to understand what magic the IDE is doing. 我正在尝试了解IDE的功能。 Which gradle tasks get executed when I click on the green button? 单击绿色按钮时会执行哪些gradle任务? How do I configure this? 我该如何配置? What gets printed out to the IDE's console? 什么输出到IDE的控制台上?

When being run in Android Studio, gradle's stdout where you can find your print statement is the "Gradle Console". 在Android Studio中运行时,可以在其中找到打印语句的gradle标准输出是“ Gradle Console”。 Hover over the square in the bottom left of the Android Studio window and you'll see lots of options to select things like Console, Maven, Event Log, etc. Select Gradle Console and you should see the output that you get when running from the command line. 将鼠标悬停在Android Studio窗口左下方的正方形上,您会看到很多选项来选择诸如Console,Maven,Event Log等之类的内容。选择Gradle Console,您应该会看到从命令行。

If you still don't see your statement being logged, chances are something isn't configured correctly inside your Android Studio project. 如果仍然看不到您的语句被记录,则可能是您在Android Studio项目中未正确配置某些内容。 Try synching your project with the gradle build file by going the top menu bar and (on a mac) Tools > Android > Sync Project with Gradle Files. 尝试通过转到顶部菜单栏和(在Mac上)工具> Android>使用Gradle文件同步项目,将项目与gradle构建文件同步。

If there are no errors in this process you should be able to see the output in the Gradle Console. 如果在此过程中没有错误,您应该能够在Gradle Console中看到输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM