android gradle 多渠道打包分发

本文介绍了如何使用Android Gradle进行多渠道打包,以便针对不同的应用市场发布,并通过统计不同市场的用户下载量进行分析。步骤包括在AndroidManifest.xml中添加meta-data标签,以及修改build.gradle文件配置。执行gradle assembleRelease命令即可生成各个渠道的APK。
摘要由CSDN通过智能技术生成

本文转载自:http://blog.csdn.net/catoop/article/details/50435431

安卓开发完成,对于一个开放应用而言,我们需要发布到不同的应用市场,同时我们也需要统计不同市场的用户下载量。(通过启动应用后获取不同市场apk中的不同值来区分)

下面用一个具体的实例来说明: 
1、在AndroidManifest.xml的application内添加meta-data标签

<code class="hljs xml has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial; "><span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">application
</span>    <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:allowBackup</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"true"</span>
    <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:icon</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"@drawable/ic_launcher"</span>
    <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:label</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"@string/app_name"</span>></span>

    <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">meta-data
</span>        <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:name</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"APP_CHANNEL"</span>
        <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:value</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"${APP_CHANNEL_VALUE}"</span> /></span>

    <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">activity
</span>        <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:name</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">".MainActivity"</span>
        <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:label</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"@string/app_name"</span> ></span>
        <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">intent-filter</span>></span>
            <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">action</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:name</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"android.intent.action.MAIN"</span> /></span>

            <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "><<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">category</span> <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(102, 0, 102); ">android:name</span>=<span class="hljs-value" style="box-sizing: border-box; color: rgb(0, 136, 0); ">"android.intent.category.LAUNCHER"</span> /></span>
        <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "></<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">intent-filter</span>></span>
    <span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "></<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">activity</span>></span>
<span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box; "></<span class="hljs-title" style="box-sizing: border-box; color: rgb(0, 0, 136); ">application</span>></span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; "><li style="box-sizing: border-box; padding: 0px 5px; ">1</li><li style="box-sizing: border-box; padding: 0px 5px; ">2</li><li style="box-sizing: border-box; padding: 0px 5px; ">3</li><li style="box-sizing: border-box; padding: 0px 5px; ">4</li><li style="box-sizing: border-box; padding: 0px 5px; ">5</li><li style="box-sizing: border-box; padding: 0px 5px; ">6</li><li style="box-sizing: border-box; padding: 0px 5px; ">7</li><li style="box-sizing: border-box; padding: 0px 5px; ">8</li><li style="box-sizing: border-box; padding: 0px 5px; ">9</li><li style="box-sizing: border-box; padding: 0px 5px; ">10</li><li style="box-sizing: border-box; padding: 0px 5px; ">11</li><li style="box-sizing: border-box; padding: 0px 5px; ">12</li><li style="box-sizing: border-box; padding: 0px 5px; ">13</li><li style="box-sizing: border-box; padding: 0px 5px; ">14</li><li style="box-sizing: border-box; padding: 0px 5px; ">15</li><li style="box-sizing: border-box; padding: 0px 5px; ">16</li><li style="box-sizing: border-box; padding: 0px 5px; ">17</li><li style="box-sizing: border-box; padding: 0px 5px; ">18</li><li style="box-sizing: border-box; padding: 0px 5px; ">19</li></ul>

2、修改build.gradle文件,在android {} 中添加

<code class="hljs cs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial; ">android {

    <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box; ">// 打包渠道List&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值