Skip to content

Instantly share code, notes, and snippets.

@MoshDev
Last active June 9, 2023 15:41
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save MoshDev/a61080cc5e1f5bafdf3cc0bf70fd86fd to your computer and use it in GitHub Desktop.
Save MoshDev/a61080cc5e1f5bafdf3cc0bf70fd86fd to your computer and use it in GitHub Desktop.
Install and Run Android App Using Gradle Task
//Place this script inside your application module build.gradle
//It will create a new task(s) based on your application variants within (run) group
//sample: ./gradlew installRunDebug
//sample: ./gradlew installRunStagDebug
project.afterEvaluate {
android.applicationVariants.all { variant ->
task "installRun${variant.name.capitalize()}"(type: Exec, dependsOn: "install${variant.name.capitalize()}", group: "run") {
commandLine = ["adb", "shell", "monkey", "-p", variant.applicationId + " 1"]
doLast {
println "Launching ${variant.applicationId}"
}
}
}
}
@DRSDavidSoft
Copy link

👍 Very nice, exactly what I needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment