<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>adt &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/adt/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Sat, 09 Oct 2010 14:48:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>adt &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Disable asset compression with Android aapt</title>
		<link>https://blog.sephiroth.it/2010/10/09/disable-asset-compression-with-android-aapt/</link>
					<comments>https://blog.sephiroth.it/2010/10/09/disable-asset-compression-with-android-aapt/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Sat, 09 Oct 2010 10:17:40 +0000</pubDate>
				<category><![CDATA[android]]></category>
		<category><![CDATA[aapt]]></category>
		<category><![CDATA[adt]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[eclipse]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=1392</guid>

					<description><![CDATA[Trying to embed all the assets resources into my final apk was not so easy as I tought.. at least using the ADT Eclipse plugin for building project. In fact, using AssetManager.openFd to return to the C++ code a FileDescriptor does not work with compressed sources. When aapt compile the resources into the apk file &#8230; <a href="https://blog.sephiroth.it/2010/10/09/disable-asset-compression-with-android-aapt/" class="more-link">Continue reading <span class="screen-reader-text">Disable asset compression with Android aapt</span></a>]]></description>
										<content:encoded><![CDATA[<p>Trying to embed all the assets resources into my final apk was not so easy as I tought.. at least using the <a href="http://developer.android.com/sdk/eclipse-adt.html" target="_blank">ADT</a> Eclipse plugin for building project.<br />
In fact, using <a href="http://developer.android.com/reference/android/content/res/AssetManager.html#openFd(java.lang.String)">AssetManager.openFd</a> to return to the C++ code a FileDescriptor does not work with compressed sources.<br />
When <a href="http://developer.android.com/guide/developing/tools/aapt.html" target="_blank">aapt</a> compile the resources into the apk file it compress by default all the files which extensions are not recognized and those which recognize as text files.</p>
<p>These are the extensions not compressed:</p>
<p>[cc]<br />
static const char* kNoCompressExt[] = {<br />
&#8220;.jpg&#8221;, &#8220;.jpeg&#8221;, &#8220;.png&#8221;, &#8220;.gif&#8221;,<br />
 &#8220;.wav&#8221;, &#8220;.mp2&#8221;, &#8220;.mp3&#8221;, &#8220;.ogg&#8221;, &#8220;.aac&#8221;,<br />
 &#8220;.mpg&#8221;, &#8220;.mpeg&#8221;, &#8220;.mid&#8221;, &#8220;.midi&#8221;, &#8220;.smf&#8221;, &#8220;.jet&#8221;,<br />
 &#8220;.rtttl&#8221;, &#8220;.imy&#8221;, &#8220;.xmf&#8221;, &#8220;.mp4&#8221;, &#8220;.m4a&#8221;,<br />
 &#8220;.m4v&#8221;, &#8220;.3gp&#8221;, &#8220;.3gpp&#8221;, &#8220;.3g2&#8221;, &#8220;.3gpp2&#8221;,<br />
 &#8220;.amr&#8221;, &#8220;.awb&#8221;, &#8220;.wma&#8221;, &#8220;.wmv&#8221;<br />
};<br />
[/cc]</p>
<p>I was looking into the .project file of my Eclipse project but it seems that changing things inside that file ( like values into the tag ) does not affect the builder.</p>
<p>The first thing I tried was to remap the aapt executable using a shell script ( and renaming the original aapt file into _aapt ):</p>
<p>[cc]<br />
#!/bin/bash</p>
<p>strParams=&#8221;&#8221;<br />
CWD=’dirname $0’</p>
<p>for i in $@; do<br />
	if [ $i = &#8220;-S&#8221; ]; then<br />
		strParams=&#8221;$(echo $strParams) -v -0 \&#8221;\&#8221;&#8221;<br />
	fi<br />
	strParams=&#8221;$(echo $strParams) $i&#8221;<br />
done</p>
<p>tool=&#8221;$CWD/_aapt $strParams&#8221;<br />
$tool 1>&#038;2<br />
[/cc]</p>
<p>In fact, when building the project in eclipse I could see the whole output, but the files are still being compressed, even if I call the same command in a shell the assets aren’t compressed.<br />
I haven’t yet find a solution so for the meantime I decided to use ant to build my project overriding the default “-package-resources” target in this way:</p>
<p>[cce]<br />
    <target name="-package-resources"><br />
        <echo>Packaging resources</echo><br />
		<echo>${asset.absolute.dir}</echo><br />
        <aapt executable="${aapt}"<br />
                command=&#8221;package&#8221;<br />
				verbose=&#8221;${verbose}&#8221;<br />
                versioncode=&#8221;${version.code}&#8221;<br />
                manifest=&#8221;AndroidManifest.xml&#8221;<br />
                assets=&#8221;${asset.absolute.dir}&#8221;<br />
                androidjar=&#8221;${android.jar}&#8221;<br />
                apkfolder=&#8221;${out.absolute.dir}&#8221;<br />
                resourcefilename=&#8221;${resource.package.file.name}&#8221;<br />
                resourcefilter=&#8221;${aapt.resource.filter}&#8221;><br />
            <res path="${resource.absolute.dir}" /><br />
            <nocompress /></target></p>
<p>
[/cce]</p>
<p>In this way the project is being compiled correctly and all my assets are embedded not compressed!</p>
<p>P.S. my claim token is: 7C8AATS7Q5A3</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2010/10/09/disable-asset-compression-with-android-aapt/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
