Android Studio - gradle task to execute after SYNC

Is there a way to execute the gradle task once after the completion of the project with the gradle files?

I tried to set the dependency of the task with preBuild, as I saw that gradle:build starts when Sync is executed. But the problem is that the dependency is not working, the task is not running, and I have to manually start the task after each synchronization.

This is basically what I have tried so far.

 apply plugin: 'com.android.library' ... task myTask { ... } gradle.projectsEvaluated { preBuild.dependsOn(myTask) } 

I also tried to establish the dependency of the task with other tasks that, as I see it, are started (: generate {Something}), but this also failed.

Is there anything you can do to complete the gradle task after each synchronization? I am using gradle 2.2.1 + Android Studio 1.0.2

+8
android android-studio gradle
source share
2 answers

Finally, I managed to run a task for each Sync event. Apparently gradle.projectsEvaluated either not executed at all during synchronization, or is executed after the build task, so the solution should completely get rid of it.

 apply plugin: 'com.android.library' ... task myTask { ... } preBuild.dependsOn(myTask) 
+9
source share

Inside the Gradle menu (usually located in the upper right corner of Android Studio) there is a list of tasks. By right-clicking on a task, you can install Execute After Sync .

enter image description here

+3
source share

All Articles