Last active
April 28, 2023 16:52
-
-
Save rozkminiacz/8efef5228659e1c6272e24c006b922cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply from: "$rootDir/run-app.gradle" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./gradlew installAndRunDebug | |
./gradlew installAndRunRelease |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android.applicationVariants.all { variant -> | |
def taskName = "installAndRun${variant.name.capitalize()}" | |
tasks.register(taskName) { | |
def artifactPath = "${variant.outputs.first().outputFile}" | |
def packageName = variant.applicationId | |
doLast { | |
def installCommand = "adb install -r ${artifactPath}" | |
def installProcess = installCommand.execute() | |
installProcess.waitFor() | |
def installOutput = installProcess.text | |
println(installOutput) | |
if (installProcess.exitValue() != 0) { | |
throw new Exception("Failed to install app.") | |
} | |
def startCommand = "adb shell am start ${packageName}" | |
def startProcess = startCommand.execute() | |
startProcess.waitFor() | |
def startOutput = startProcess.text | |
println(startOutput) | |
if (startProcess.exitValue() != 0) { | |
throw new Exception("Failed to start app") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment