如何提供不同的Android应用程序图标不同摇篮buildTypes? [英] How to provide different Android app icons for different gradle buildTypes?
问题描述
我在我的摇篮文件中设置两种构建类型:调试
和发布
。我希望能够设置一个不同的应用程序图标,调试
生成类型。有什么办法来此只是通过共建型,不进入产品的口味? build.gradle文件如下:
应用插件:'机器人'
// ...
安卓{
compileSdkVersion 19
buildToolsVersion19.0.3
defaultConfig {
的minSdkVersion 14
targetSdkVersion 19
版本code 30
VERSIONNAME2.0
}
buildTypes {
调试{
packageNameSuffix的.debug
versionNameSuffix-SNAPSHOT
}
推出 {
runProguard假
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
}
}
}
依赖{
编译文件树(导演:库,包括:['的* .jar'])
}
想通了。你需要做的是创建一个名为调试
持有不同的图标,一个单独的src文件夹。例如,如果你的项目布局如下,你的发射器的图标被称为 ic_launcher.png
:
[项目根]
- [模块]
-src
-主要
-res
-drawable- *
-ic_launcher.png
然后添加一个单独的图标,调试构建类型,您添加:
[项目根]
- [模块]
-src
-主要
-res
-drawable- *
-ic_launcher.png
-debug
-res
-drawable- *
-ic_launcher.png
然后,当你在调试版本类型构建,它将使用在debug文件夹中找到的ic_launcher。
I have two build types set in my gradle file: debug
and release
. I'd like to be able to set a different app icon for the debug
build type. Is there any way to this just through the build type, without getting into product flavors? build.gradle file is below.
apply plugin: 'android'
//...
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 30
versionName "2.0"
}
buildTypes {
debug {
packageNameSuffix '.debug'
versionNameSuffix '-SNAPSHOT'
}
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
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.
这篇关于如何提供不同的Android应用程序图标不同摇篮buildTypes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!