1. 在安卓中对release和debug打包的app设置不同的图标和应用名
2. 设置打包时的名称(加上版本号和渠道等)
同理可以设置一些动态的变量在gradle中,然后让程序打包时自行 取值
示例1
release {
debuggable false
minifyEnabled true
zipAlignEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "ENV_SETTING", "true"
buildConfigField("boolean", "isAppCheckUpdate", "true")
buildConfigField("Boolean", "isModule4SubApp", String.valueOf(rootProject.ext.isModule))
resValue "string", "app_name", "xxxx_release"
buildConfigField("Boolean", "isModule4SubApp", String.valueOf(rootProject.ext.isModule))
}
示例2
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "weatherspeaker_v${defaultConfig.versionName}.apk"
}
}
manifestPlaceholders = [
app_icon: "@mipmap/ic_launcher2",
app_name: "@string/app_name"
]
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "weatherspeaker_v${defaultConfig.versionName}_debug.apk"
}
}
manifestPlaceholders = [
app_icon: "@mipmap/ic_launcher_debug",
app_name: "@string/app_name_debug"
]
}
}
在manifest中设置
<application
android:name=".App"
android:allowBackup="true"
android:icon="${app_icon}"
android:label="${app_name}"
android:roundIcon="${app_icon}"
android:supportsRtl="true"
android:theme="@style/AppTheme">
|