When running:
ant release
with my Android project, I get a ton of auto generated files. For example:
MyApp-release-unaligned.apk
MyApp-release-unsigned.apk
MyApp-release-unsigned.apk.d
MyApp-release.apk
MyApp.ap_
MyApp.ap_.d
build.prop
classes
classes.dex
classes.dex.d
res
I don’t want all these files. Basically all I need is the signed .apk. So I tried:
<target name="-post-compile">
<!-- Clean up files that we don't want -->
<delete dir="{$out.dir}res"/>
<delete dir="{$out.dir}classes"/>
<delete file="{$out.dir}${app.name}-release-unaligned.apk"/>
<delete file="{$out.dir}${app.name}-release-unsigned.apk"/>
<delete file="{$out.dir}${app.name}-release-unsigned.apk.d"/>
<delete file="{$out.dir}${app.name}.ap_"/>
<delete file="{$out.dir}${app.name}.ap_d"/>
<delete file="{$out.dir}build.prop"/>
<delete file="{$out.dir}classes.dex"/>
<delete file="{$out.dir}classes.dex.d"/>
</target>
Evidently these files are generated after -post-compile is called. Is there an easy way to adjust the build.xml to remove all but the signed apk? My output directory is directed to a server and I would like to keep things simple there so that others don’t pull the wrong file. If there is no easy way to remove these files, I’ll build a server-side script to do it but I would prefer to keep everything in the build.xml if possible. Thanks!
You can add the target of removing the files as last line of the release command, however, I assume you don’t create your own release target as most Android developers. Then another alternative will be to expose your target as say
<target name="remove-files">and run the ant release likeant release,remove-files.However, I just wonder why are those files such a bug burden?