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,