Android Rocket Launcher

Additional

Language
Kotlin
Version
0.2.2 (May 29, 2016)
Created
May 28, 2016
Updated
Feb 10, 2020 (Retired)
Owner
César Ferreira (cesarferreira)
Contributor
César Ferreira (cesarferreira)
1
Activity
Badge
Generate
Download
Source code

Android Rocket Launcher

Gradle plugin that adds tasks to your android modules for installing and launching all variants

How to use

Paste this code into your main build.gradle

dependencies {
    // ...
    classpath 'com.cesarferreira:android-rocket-launcher:1.0.0'
}

Paste this code into your app module build.gradle

apply plugin: 'android-rocket-launcher'

Now, when you run ./gradlew tasks, you'll see something like this:

openDevDebug - Installs and opens DevDebug build
openDevRelease - Installs and opens DevRelease build
openEnvtestDebug - Installs and opens EnvtestDebug build
openEnvtestRelease - Installs and opens EnvtestRelease build
openProdDebug - Installs and opens ProdDebug build
openProdRelease - Installs and opens ProdRelease build
openSandboxDebug - Installs and opens SandboxDebug build
openSandboxRelease - Installs and opens SandboxRelease build

Alternative

Copy-pasting this gradle task on every project

// Running the APK on your Android Device
android.applicationVariants.all { variant ->
    if (variant.install) {
        tasks.create(name: "run${variant.name.capitalize()}", type: Exec,
                dependsOn: variant.install) {
            group = 'Run'
            description "Installs and Runs the APK for ${variant.description}."
            def getMainActivity = { file ->
                new XmlSlurper().parse(file).application.activity.find {
                    it.'intent-filter'.find { filter ->
                        return filter.action.find {
                            it.'@android:name'.text() == 'android.intent.action.MAIN'
                        } \
                                 && filter.category.find {
                            it.'@android:name'.text() == 'android.intent.category.LAUNCHER'
                        }
                    }
                }.'@android:name'
            }
            doFirst {
                def activityClass =
                        getMainActivity(variant.outputs.processManifest.manifestOutputFile)
                commandLine android.adbExe, 'shell', 'am', 'start', '-n',
                        "${variant.applicationId}/${activityClass}"
            }
        }
    }
}

It's a no brainer 😄

Maintainers

License

MIT