In the process of using Gradle for multi-channel packaging, refer to the blog post: http://blog.csdn.net/qihigh/article/details/17922345 (thank you here first)
However, in the process of using Gradle ASSEMBLERELEASE-PMC does not get all the packages I want, the reason is: the author used the BuildType as the definition of the channel type , this does not meet my needs. and in my understanding, multi-channel should be flavor, so I have to re-write a flavor script
def falvors = Getmyflavorsfromfilesystem (); productflavors{ prod { } dev{ } _4t{} falvors.each{name,config-> "$name" { sourcesets["$name"].res.srcdirs = [Config.rrrr]}}
This allows the APK to be generated as expected when using ASSEMBLERELEASE-PMC
Attach the relevant code:
Def getmyflavorsfromfilesystem () { flavors = [:] if (project.hasproperty (' MC ')) { println '------setup Flavors---------------' def path = './build-type/type.txt ' def prefix = ' _ ' file (path). eachline{Line- > println line def f = File ("./build-type/$line") if (!f.exists ()) { f.mkdir () } def Respath = File ("./build-type/$line/res-" + prefix+line) if (!respath.exists ()) { respath.mkdir () } copyres (respath.absolutepath,line) flavors.put (prefix+line,[ rrrr:respath ]) } } return Flavors}
Reference Documentation:
Android automatically builds multi-platform packages
Dynamically-generating-product-flavors
And this one.
Android uses Gradle to dynamically generate multi-channel apk