Add in Build.gradle
productflavors{
LeTV {
ApplicationID "xxxxxxxxxxx"//Package Name
Buildconfigfield "boolean", "XXX", "true"//Add Boolean buildconfig.xxx
}
}
Dynamically modify the Icon,label according to the Productflavors Name property
Productflavors.all {
Flavor
if (name.equals ("xxx")) {//and the variable name in Buildconfig above corresponds
Flavor.manifestplaceholders = [Channel_name:name, App_label: "@string/app_name", App_icon: "@mipmap/ic_launcher"]
} else {
Flavor.manifestplaceholders = [Channel_name:name, App_label: "@string/app_name1", App_icon: "@mipmap/ic_launcher1"]
}
}
Androidmanifest.xml Modification:
<application
Android:name= ". Application "
Android:hardwareaccelerated= "true"
Android:label= "${app_label}"
Android:largeheap= "true"
Android:theme= "@style/apptheme"
Tools:replace= "Android:label,android:icon"
In the application layer development, the BUILDCONFIG.XXX is used to judge and execute different blocks of code.
Android Gradle for multi-channel number packaging