文/ 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的基本配置