Android uses Gradle to dynamically generate multi-channel apk

Source: Internet
Author: User

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

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.