Running a task after a packageApplication application using the android gradle plugin

Gradle has the ability to run tasks after completing other tasks. Syntax taskY.mustRunAfter taskX . The android gradle plugin says that one of the ApplicationVariant tasks that it defines is packageApplication .

In my build.gradle I have taskX.mustRunAfter packageApplication

The error I am getting is' Could not find property 'packageApplication' on project ': someproject'. "

Is it possible to access the packageApplication task? If this is considered bad practice?

+3
source share
2 answers

Pay attention to this suggestion from the documentation:

" ", , taskB taskA, , taskA taskB .

,

taskX.mustRunAfter packageApplication

taskX packageApplication, :

./gradlew taskX packageApplication

, , taskX.

- , doLast:

taskX.doLast{ println 'Hello' }

packageApplication ApplicationVariant, . package<VariantName>.

+1

. rciovati mustRunAfter , , . taskY groovy. :

android.applicationVariants.all { variant ->
    // rename apk after we assemble the application
    variant.assemble.doLast {
        taskY(variant)
}
+8

All Articles