Apply the plugin in your app module's build.gradle file:
apply plugin: 'app-icon-overlay'
appiconoverlay {
/* then see below for configuration options */
}
android {
/* project config */
}
For those using Gradle 3.+ disable aapt2 in your app module's gradle.properties file:
android.enableAapt2=false
You will need convert from the ImageMagick project to do the image processing. You can install it using a command along the lines of:
# debian/ubuntu
sudo apt-get install imagemagick
# osx
sudo port install imagemagick
sudo brew install imagemagick
# required on osx otherwise imagemagick (silently) goes into an infinite loop complaining about missing fonts
sudo brew install ghostscript
The plugin will hook into your build process automatically and overwrite the target app icon files for debug builds. It will not mess with any files in your repository.
Customization
The plugin offers some options for customizing the appearance of the generated icon. Simply add a block to your app module's build.gradle:
appiconoverlay {
textColor '#FFF'/* #rrggbbaa format */
backgroundColor "#0008"/* #rrggbbaa format */
format '$build->$branch\n$commit'/* GString */
imageMagick 'convert'/* command to run ImageMagick */
}
Option
Description
textColor
Text color in #rrggbbaa format.
backgroundColor
Background color for overlay in #rrggbbaa format.
format
Format string to be used to create the text in the overlay. Note: Use single quotes, it's a GString. The following variables are available:
$branch name of git branch
$commit short SHA1 of latest commit in current branch
$build the name of the build variant ex. Debug
imageMagick
Command to run ImageMagick's "convert".
Building locally
If you want to make changes to the plugin, here's how you can build it locally and test it with an Android app:
Check out the project using git.
In the root directory, run gradle jar.
Find the generated .jar file in ./build/libs/.
To reference your local .jar file in your Android project, declare the dependency as follows in the project's top-level build.gradle file:
请发表评论