Modify the launcher icon of each of your app-variants using simple Gradle rules. Add ribbons of any color, overlay your own images, customize it according to your needs!
Circle | RoundedRectangle | Teardrop |
---|---|---|
This library heavily relies on the original Akaita's easylauncher plugin, but introduces supports for modern build tools and Vector icons
// in app/build.gradle
plugins {
id "com.starter.easylauncher" version "${{version}}"
}
see Gradle Plugin Portal for the details
What should I do if I get `Could not resolve all artifacts` error?
In some configurations a dependency resolution error might be thrown with a message:
Could not find com.android.tools.build:gradle:x.x.x`.
As a solution apply the plugin to the root project using:
// in root project's build.gradle
buildscript {
repositories.google()
}
plugins {
id "com.starter.easylauncher" version "${{version}}" apply false
}
then apply the plugin in your application module:
// in app/build.gradle
plugins {
id "com.starter.easylauncher"
}
See related issue for more information.
By default, the plugin applies green ribbon for all debuggable build variants. You can customize the filters applied to each type, flavor and variant of your app.
Imagine these are the type and flavors of your app:
// in app/build.gradle
android {
buildTypes {
debug {
//Debuggable, will get a default ribbon in the launcher icon
}
beta {
//Debuggable, will get a default ribbon in the launcher icon
debuggable true
}
canary {
//Non-debuggable, will not get any default ribbon
debuggable false
}
release {
//Non-debuggable, will not get any default ribbon
}
}
productFlavors {
local {}
qa {}
staging {}
production {}
}
}
You could customize the plugin's behaviour like this:
easylauncher {
defaultFlavorNaming true // Use flavor name for default ribbon, instead of the type name
productFlavors {
local {}
qa {
// Add one more filter to all `qa` variants
filters redRibbonFilter()
}
staging {}
production {}
}
buildTypes {
beta {
// Add two more filters to all `beta` variants
filters = [
customRibbon(ribbonColor: "#0000FF"),
overlayFilter(file("example-custom/launcherOverlay/beta.png"))
]
}
canary {
// Remove ALL filters to `canary` variants
enable false
}
release {}
}
variants {
productionDebug {
// OVERRIDE all previous filters defined for `productionDebug` variant
filters = orangeRibbonFilter("custom")
}
}
}
By default, the plugin automatically discovers launcher icon and applies provided filters.
Custom icon names, useful i.e. when defining multiple activity aliases, can be provided using iconNames
property as follows:
easylauncher {
iconNames = ["@mipmap/custom_launcher_icon"] // optional, disables automatic launcher icon discovery and will use provided icons only
buildTypes {
beta {
// icon names can also be provided per each configuration (buildType, productFlavor or variant)
iconNames = ["@mipmap/beta_launcher"]
}
}
}
Command | Result |
---|---|
overlayFilter(file("example-custom/launcherOverlay/beta.png")) |
Troubleshooting on "Problem reading font data."
When using docker or a minimalistic environment one might encounter above error message when loading Fonts.
The solution is to make sure font support was installed i.e. by calling:
apk add --no-cache freetype fontconfig ttf-dejavu
See related issue for more information.
defaultFlavorNaming
: use flavor name in default ribbons, instead of using buildTypeenable
: enable/disable all filters for a flavor/type/variantproductFlavors
: define filters for flavors (will be added to filters defined for types)buildTypes
: define filters for types (will be added to filter defined for flavors)variants
: define filters for variants (will override any other filters)iconNames
: provides a list of icons which will have the filters applied
Minimal requirements for the plugin are:
- Gradle: 6.5
- Android Gradle Plugin: 4.1.0
- Java Version: 8
- minSdkVersion: 21 (theoretically there should be no lower boundary - it just hasn't been tested)
easylauncher/ - source code of Gradle plugin
sample/ - root directory of supported Android applications which serve as test projects
Credits to Akaita's easylauncher plugin which this project heavily relies on