Originally planned today to send Android official technical document translation-"Gradle plug-in User Guide" of the fifth chapter, but because last night did not finish translation, still a few paragraphs, so had to postpone.
Let's talk today about using Gradle to do multi-channel packaging like the Friends Alliance.
This article original, reproduced please note on the csdn on the source:
http://blog.csdn.net/maosidiaoxian/article/details/42000913
At present, I have mastered two methods, are very simple, with the Gradle Android plugin in the productflavors.
As an example of a friend's multi-channel package, let's say we need to package the following channels: Umeng, Wandoujia, Yingyongbao.
The first method is to create a file.
After we have finished writing our code, under APP/SRC, create the folder Umeng, Wandoujia, Yingyongbao, respectively, with the main sibling directory, Each of the three folders has only one androidmanifest.xml file, the file only needs to be as follows:
<manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "Your.package.name" > <application> <meta-data android:name= "Umeng_channel" android:value= "Umeng"/> </ Application></manifest>
Note that the value above should correspond to the name of your channel. For example, the Wandoujia should correspond to the channel name on your pea pod (e.g. Wandoujai).
Then in your Build.gradle android{} node, add the Productflavors node, the code is as follows:
Android { //Here is your other configuration productflavors{ umeng{ } wandoujai { } yingyongbao{ } } //Your other configuration}
Note that the name of the flavors here corresponds to the name of your folder. Once this is configured, the multi-channel apk is built.
The second way, without creating those files, it uses another feature in the Gradle Android plugin, manifestplaceholders.
In this approach, you only need to configure the Androidmanifest.xml channel in this way:
<meta-data android:name= "Umeng_channel" android:value= "${channel_name}"/>
Then use the same productflavors, but then it's configured like this:
Android { //Your other configuration code productflavors { Yingyongbao { manifestplaceholders = [Channel_name: " Yingyongbao "] } Umeng { manifestplaceholders = [channel_name:" Umeng "] } Wandoujia { Manifestplaceholders = [channel_name: "Wandoujia"] } } //Your other Configuration code}
In the above, we can also specify a default channel name, if necessary. Specifying the default value is to add the following to the Defaultconfig node:
Manifestplaceholders = [channel_name: "Unspecified"]
The unspecified here is replaced by your actual default channel name.
Using this configuration of Manifestplaceholders, the same applies to other configurations of manifest. For example, you need to specify different launch activity in the APK that is released from different channels. For example, in the Pea pod released, the activity shown is the start of the Pea pod interface, App Bao is launched in the app Bao first interface (haha, a bit bad), you can use the value of your activity ${activity_name} way, Then configure the value of this ${activity_name} inside the productflavors.
This article by 6K Bo Master Original, reproduced please indicate the source:
http://blog.csdn.net/maosidiaoxian/article/details/42000913
or Geek_soledad
This article by 6K Bo Master Original, reproduced please indicate the source:
http://blog.csdn.net/maosidiaoxian/article/details/42000913
or Geek_soledad
Very simple multi-channel packaging method