1. 在APP下的gradle文件中,建立不同的产品名称 flavorDimensions "app" productFlavors { camb { dimension "app" manifestPlaceholders = [ CHANNEL_NAME:"CAMB", APP_NAME:"@string/camb", APP_ICO:"@drawable/camb_icon2" ] } }
2. 在APP下的gradle文件中defaultConfig中添加默认编译代码
manifestPlaceholders = [ CHANNEL_NAME:"CAMB", APP_NAME:"@string/camb", APP_ICO:"@mipmap-hdpi/camb_icon2" ]
3. 在AndroidManifest.xml文件中使用动态值
<application
android:allowBackup="true"
android:icon="${APP_ICO}"
android:label="${APP_NAME}"
tools:replace="android:label"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
注意红色文字默认没有,需要手动添加。