I would like to take the generated signed bundle from Android Studio and generate all apks and install them on every device that is connected to my computer at that time.
I know how to generate the apks and install them but I don't know how to run that script after a signed bundle is created. I only want this to run when I use Build -> Generate signed bundle/apk and choose a bundle and the production release flavor.
Can I do that with gradle?
Thanks.
Android tasks are typically created in the "afterEvaluate" phase. Starting from gradle 2.2, those tasks also include "assembleDebug" and "assembleRelease". To access such tasks, the user will need to use an afterEvaluate closure:
afterEvaluate { assembleDebug.dependsOn someTask }
source: https://code.google.com/p/android/issues/detail?id=219732#c32
try add this in you app/build.gradle
afterEvaluate {
assembleRelease.doLast {
android.applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
def releaseBuildTask = tasks.create(name: "release") {
println(".................... test ..............................")
}
releaseBuildTask.mustRunAfter variant.assemble
}
}
println "build finished"
}
}
invoke the build command and specify the task assembleRelease
./gradlew assembleRelease
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With