Android uses Gradle to dynamically generate multi-channel APK and gradleapk

Source: Internet
Author: User

Android uses Gradle to dynamically generate multi-channel APK and gradleapk

In the process of using gradle for multi-channel packaging reference blog: http://blog.csdn.net/qihigh/article/details/17922345 (here first thank you)

However, when using gradle assumerelease-Pmc, I cannot get all the packages I want. The reason is:The author uses buildType as the Channel Definition type.This cannot meet my needs.In my understanding, multiple channels should be flavor.So I re-wrote the flavor script.

def falvors = getMyFlavorsFromFileSystem();    productFlavors{        prod {        }        dev{        }        _4T{}        falvors.each{name,config->            "$name"{                sourceSets["$name"].res.srcDirs = [config.rrrr]            }        }    }

In this way, the apk can be generated according to the expected package when using assumerelease-Pmc.

Add 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:

Android automatically builds multi-platform packages

Dynamically-generating-product-flavors

And this




Related Article

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.