文/ skay
csdn博客:http://blog.csdn.net/sk719887916/article/details/40541163
最近遇到项目从Eclispe迁移到Android studio,以前的Ant自动打包脚本已经兼容不好了,所以用了Gradle实现打渠道包,切换环境等,
Ant打包脚本
<target name="-release-sign" if="has.keystore">
<!-- only create apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not create apk...">
<sequential>
<property name="out.unaligned.file"
location="${out.absolute.dir}/${ant.project.name}-release-unaligned.apk"/>
<!-- Signs the APK -->
<echo level="info">Signing final apk with your apk signer server...</echo>
<taskdef resource="com/myapk/ant/task/defaults.properties" classpath="${signer.jar}"/>
<apk-signer
server="http://xxx.com/packservice/sign<pre name="code" class="html" style="font-size: 14px; line-height: 26px;">
</pre><p><pre name="code" class="html">" apk="${out.packaged.file}" dest="${out.unaligned.file}" prodkey="${singer.prodkey}" verbose="true" timeout="500" retries="5" /> <!-- Zip aligns the APK --> <zipalign-helper in.package="${out.unaligned.file}" out.package="${out.final.file}"/> <echo level="info">Release Package: ${out.final.file}</echo> </sequential> </do-only-if-not-library> <record-build-info/> </target>
Gradle
加入配置,签名文件,配置打包生成apk文件名称规则,配置url,配置渠道等
配置gradle
android {}配置一些关于android的基本配置
1配置依赖关系

本文介绍了如何使用Android Studio的Gradle进行多渠道自动打包,包括动态修改HostUrl、配置签名文件、混淆设置等步骤。通过配置Gradle脚本,实现了在打包时自动切换URL、指定渠道版本和签名,简化了项目从Eclipse迁移至Android Studio的过程。
最低0.47元/天 解锁文章
1316

被折叠的 条评论
为什么被折叠?



