Android studio uses gradle for multi-channel packaging, androidgradle

Source: Internet
Author: User

Android studio uses gradle for multi-channel packaging, androidgradle

I tried to use gradle in android studio to program a multi-channel package, which is as amazing as it is. In this article, I will refer to the content on Google. Here is the right-to-learn record.


1. Configure the channel information in AndroidManifest. xml. Here we take umeng statistics as an example.

Add the following to the <application>... </application> node:
<meta-data android:name="UMENG_CHANNEL" android:value="${UMENG_CHANNEL_VALUE}"></meta-data>


Note that in the past, the value is the channel name. For example, wandoujia can be entered for pods, but $ {UMENG_CHANNEL_VALUE} can be used as a variable here, which will be used below;
2. build. gradle in the module of the corresponding package:

Add the following changes to android:
productFlavors{        wandoujia{}        qihu360{}        baidu{}        xiaomi{}        uc{}        productFlavors.all{            flavor->flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]        }    }



Among them, wandoujia {} And qihu360 {}...... these are the channel names needed, and the UMENG_CHANNEL_VALUE here is for our AndroidManifest. configure the value of the channel information in xml, add these items, and then build the project:
After the operation is successful, proceed to the next step;
3. Configure the gradle environment variable and add the binfile path in gradle to the path;

4. How to pack the signature? Select Build-> Generate Signed APK...

Enter the signature and password, and you will see this:

Select all Flavors options and finish. OK. You can see the named apk In the module Directory,

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.