使用 ant 为不同市场导出多个 apk [英] Export multiple apk for different market using ant
问题描述
我的 Android 应用面向 20 多个市场,每个市场在 Manifest.xml 中都有几个不同的属性.
一个接一个发布20+个apk真的很费时间,我试着用windows批处理文件一键搞定.
目前,我使用教程这里提供的解决方案来改变Manifest.xml 中的字段,但我不太了解 ant,所以我使用了一种非常hack 的方法在批处理文件中完成这项工作,如下所示:
My Android app is targeted to 20+ market, each with several different properties in the Manifest.xml.
To release 20+ apk one after another is really time-consuming, and I tried to use the windows batch file to do the release job in a single click.
For now, I use the solution provided by the tutorial here to change the field in the Manifest.xml, but I don't know ant well, so I use a very hack method to do the job in batch file like below:
start cmd.exe /c "ant config-google-play release_mine"
REM the line below is for waiting for the former task to finish
ping 1.1.1.1 -n 1 -w 90000 > nul
start cmd.exe /c "ant config-eoemarket release_mine"
ping 1.1.1.1 -n 1 -w 90000 > nul
....
有什么优雅的方法来实现这一点吗?就像在 build.xml 中编辑目标以在 ant 中完成一样.
Is there some elegant way to accomplish this? like just editing targets in build.xml to do it in ant, etc.
推荐答案
我的最终解决方案:
定义任务:
My final solution:
Define task:
<target name="modify_manifest">
<property
name="version.market"
value="${channel}"/>
<property
name="out.final.file"
location="${out.absolute.dir}/${ant.project.name}_${channel}_${project.version.name}.apk"/>
<antcalltarget="release"/>
</target>
然后在此处包含 ant-contrib*.jar 作为 answer 以便我可以使用在蚂蚁中循环.然后在下面定义一个新任务
Then include ant-contrib*.jar as the answer here so that I can use loop in ant. Then define a new task below
<target name="deploy" >
<foreach
delimiter=","
list="${market_channels}"
param="channel"
target="modify_manifest" >
</foreach>
</target>
使用ant deploy"来完成任务.
market_channels 应在 ant.property 中定义如下:
Use "ant deploy" to do the task.
market_channels should be defined in ant.property as follow:
market_channels=google-play,other,...
这篇关于使用 ant 为不同市场导出多个 apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!