如何通过Gradle构建大量的apk,唯一的区别是资产文件

时间:2013-07-02 14:12:20

标签: android build.gradle

我想使用Gradle build Android。 所有appStores都有近100个apk。唯一的区别是assets / config.properties文件。

Ant脚本:                                     

<target name="makechannelidapk">
    <propertyregex property="channel_id" input="${line_content}" regexp="(.*)," select="\1"/>
    <delete file="${asset-dir}/config.properties" />
    <echo file="${asset-dir}/config.properties"CHANNEL_ID=${channel_id}</echo>

    <antcall target="finalmake" >
        <param name="id" value="${client_source}"/>
    </antcall>
</target>

1 个答案:

答案 0 :(得分:0)

使用元数据

的AndroidManifest.xml

<div class="row" style="width:800px">
    <div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                Properties
            </div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-6">
                        <dl class="dl-horizontal">
                            <dt>Property 1</dt>
                            <dd>
                                Value 1
                            </dd>
                        </dl>
                    </div>
                    <div class="col-md-6">
                        <dl class="dl-horizontal">
                            <dt>Property 2</dt>
                            <dd>
                                Value 2
                            </dd>
                        </dl>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                Properties
            </div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-6">
                        <dl class="dl-horizontal">
                            <dt>Property 1</dt>
                            <dd>
                                Value 1
                            </dd>
                        </dl>
                    </div>
                    <div class="col-md-6">
                        <dl class="dl-horizontal">
                            <dt>Property 2</dt>
                            <dd>
                                Value 2
                            </dd>
                        </dl>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

的build.gradle

<meta-data android:value="${CHANNEL_VALUE}" android:name="CHANNEL"/>

获取元数据

    android {
    defaultConfig {
        ...
        // default CHANNEL_VALUE
        manifestPlaceholders = [CHANNEL_VALUE: "default"]
    }
    productFlavors {
        fir{}
        wandoujia{}
        qihu360{}
        baidu{}
        xiaomi{}
        uc{}
        productFlavors.all{
            flavor->flavor.manifestPlaceholders = [CHANNEL_VALUE: name]
        }
    }
}