Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.cesarferreira:android-rocket-launcher:0.9.1'
}
dependencies {
implementation("com.github.cesarferreira:android-rocket-launcher:0.9.1")
}
<dependency>
<groupId>com.github.cesarferreira</groupId>
<artifactId>android-rocket-launcher</artifactId>
<version>0.9.1</version>
</dependency>
libraryDependencies += "com.github.cesarferreira" % "android-rocket-launcher" % "0.9.1"
:dependencies [[com.github.cesarferreira/android-rocket-launcher "0.9.1"]]
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
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 :smile:
MIT