Android Gradle for multi-channel number packaging

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.