Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass arguments to aapt when building android apk?

I'm building an apk using ant on Linux (not using Eclipse), and I'm trying to find an easy way to switch between compressing assets and not, in order to keep my huge database uncompressed for < 2.3. As per this article:

http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/

I see that it's possible to do this by specifying something like aapt -0 db, but I can't find information on how to edit the way ant interacts with aapt. Or do I have to run aapt by itself? What do I do?

like image 652
yuttadhammo Avatar asked Feb 23 '23 13:02

yuttadhammo


1 Answers

It's Android's build.xml (you'll find this under your SDK, tools and ant) that executes AAPT when building.

Find your build.xml and replace the "-package-resources" target with the target below. I'm pretty sure (not able to test it at the moment) you'd be able to swith compression on and off with either "-Dcompression.disabled=set" when build with ANT or "compression.disabled=set" in your .properties-file.

<target name="-package-resources" depends="-crunch">
    <!-- only package resources if *not* a library project -->
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <aapt executable="${aapt}"
                command="package"
                versioncode="${version.code}"
                versionname="${version.name}"
                debug="${build.is.packaging.debug}"
                manifest="AndroidManifest.xml"
                assets="${asset.absolute.dir}"
                androidjar="${android.jar}"
                apkfolder="${out.absolute.dir}"
                nocrunch="${build.packaging.nocrunch}"
                resourcefilename="${resource.package.file.name}"
                resourcefilter="${aapt.resource.filter}"
                projectLibrariesResName="project.libraries.res"
                projectLibrariesPackageName="project.libraries.package"
                previousBuildType="${build.last.target}"
                buildType="${build.target}">
            <res path="${out.res.absolute.dir}" />
            <res path="${resource.absolute.dir}" />
            <if>
                <condition>
                    <isset property="compression.disabled" />
                </condition>
                <then>
                    <nocompress/>
                </then>
            </if>
        </aapt>
    </do-only-if-not-library>
</target>
like image 139
Sveinung Kval Bakken Avatar answered Mar 03 '23 00:03

Sveinung Kval Bakken