How to Provide Different Android App Icons for Different Gradle Buildtypes

How to provide different Android app icons for different gradle buildTypes?

Figured it out. What you need to do is create a separate src folder called debug that holds the different icons. For example, if your project layout is as follows, and your launcher icon is called ic_launcher.png:

[Project Root]
-[Module]
-src
-main
-res
-drawable-*
-ic_launcher.png

Then to add a separate icon for the debug build type, you add:

[Project Root]
-[Module]
-src
-main
-res
-drawable-*
-ic_launcher.png
-debug
-res
-drawable-*
-ic_launcher.png

Then, when you build under the debug build type, it will use the ic_launcher found in the debug folder.

How do I get different icons for the two versions of my GPS app generated via gradle build variants?

I can't make the two versions have different icons and I can't make the action bar display different titles for the different apps.

Step #1: Choose one (free or paid) to be the one you have in the main/ sourceset. For the purposes of this answer, I'll assume that the free one goes in main/.

Step #2: Edit main/res/values/strings.xml to have your desired free edition of the app_name resource, as you are using the app_name string resource in your manifest.

Step #3: Create a paid/res/values/strings.xml with a definition of app_name that contains your desired value for the paid app's display name.

Step #4: Decide whether you are going to use mipmaps or drawables for your launcher icon. You seem to have mipmap directories, but your manifest references a drawable resource. For the purposes of this answer, I will assume that you will go with mipmaps.

Step #5: Decide what you are going to call the launcher icon. Your app presently does not build, it would appear, as your manifest refers to a kc_icon_free drawable, but your directory listing shows ic_launcher. In particular, you want the name to NOT refer to "free" or "paid". I will assume here that you go with ic_launcher.

Step #6: Get your icons and manifest reorganized per the above, with your free edition of the icons in the main sourceset.

Step #7: Create paid/res/mipmap-*/ directories and put the paid edition of ic_launcher icons in there.

Since we're dealing with flavors, there are three AndroidManifest.xml files: one I CAN edit and two that gradle generates, one for each flavor. If I edit those, the edits are lost with the next build.

You are certainly welcome to have AndroidManifest.xml files in the free and paid sourcesets. They will get merged with the one in main, the Gradle settings, and manifests from any dependencies.

That being said, you don't need that here. Have one manifest, pointing to one set of resources for labels and icons. Have one edition of the labels and icons in the main sourceset; have the other in a product flavor's sourceset (e.g., paid per my steps above).

Why does the title in the action bar for both versions show as a fully-qualified package name?

Presumably, that is what you have for the app_name string resource value. If you do not like it, change the string resource.

Is there a way to edit the generated AndroidManifest.xml files?

Not the merged ones.

Or to make each flavor have its own editable AndroidManifest.xml?

See above. Again, that's not the right solution for your problem.

Android - app icon for debug and release mode

as far as i know app icons are only dependent on the drawables folder they are in, and there is no folder qualifiers for -debug and there's no way for you to alter the icon based on manifest changes



Related Topics



Leave a reply



Submit