简体   繁体   English

在Gradle Sync上自动重建Android Studio项目

[英]Automatically Rebuild Android Studio Project on Gradle Sync

How do you run a Gradle command everytime the project syncs (though the sync button after changing Gradle files)? 每次项目同步时,如何运行Gradle命令(尽管在更改Gradle文件后使用同步按钮)? Specifically, I would like to run "Rebuild project" or "clean, generateSources". 具体来说,我想运行“重建项目”或“清理,generateSources”。

Go to View->Tool window->Gradle There you can pick the gradle task you want and right click it and choose execute before sync 转到“视图”->“工具”窗口->“渐变”,您可以在其中选择所需的gradle任务,然后右键单击它并选择“同步前执行”

You can also create a shortcut to that task 您还可以创建该任务的快捷方式

At Time of gradle process you can't rebuild project you should wait for completion. 在gradle过程中,您无法重建项目,您应该等待完成。

But to rebuild project from android studio follow these steps: 但是要从android studio重建项目,请按照以下步骤操作:

1)Go to Build(alt + B)
2)Click on Rebuild.

If you want to sync gradle then follow below steps: 如果要同步gradle,请按照以下步骤操作:

1)Go to Tools(alt + T)
2)Android ->
3)Now click on Sync Project with Gradle File
(OR from toolbar click on gradle icon which right of AVD Manager)

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

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