Android - app icon for debug and release mode

2019-04-21 06:13发布

Is it possible to set separate icons for application if we set android:debuggable=true in manifest and if we set android:debuggable=false like in iOS?

7条回答
成全新的幸福
2楼-- · 2019-04-21 07:16

A bit late but I'll leave my solution for who is looking for the same answer.

On the build.gradle where the buildTypes are defined, I added a suffix for my debug_test build type to have a different apk installed on my device.

buildTypes {
    release {
        ...
    }
    debug_test {
        debuggable true
        applicationIdSuffix '.debug'
        ...
    }
}

After that, go to File > New > Android Resource Directory and create a new mipmap resource directory for your debug_test build type (as you can see on Source set):

Create new Resource directory

I've created the mipmap folder because it's the folder for placing your app/launcher icons in only. All the other images should be placed in the drawable folders.

Add the ic_launcher icon to the folder created (app > src > res > mipmap > ic_launcher.png).

enter image description here

Now, just reference your icon on your AndroidManifest as below:

<application
    android:name=".MyApplication"
    android:icon="@mipmap/ic_launcher"
    ...
</application>

And the magic is done!

查看更多
登录 后发表回答