构建 android apk 时如何将参数传递给 aapt?

发布于 2024-12-13 02:03:35 字数 419 浏览 2 评论 0原文

我正在Linux上使用ant(不使用Eclipse)构建一个apk,并且我正在尝试找到一种在压缩资产和不压缩资产之间切换的简单方法,以便使我的巨大数据库保持未压缩< 2.3.根据本文:

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

我发现可以通过指定类似的内容来做到这一点aapt -0 db,但我找不到有关如何编辑 ant 与 aapt 交互方式的信息。或者我必须自己运行 aapt 吗?我该怎么办?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终止放荡 2024-12-20 02:03:35

构建时执行 AAPT 的是 Android 的 build.xml(您可以在 SDK、工具和 ant 下找到它)。

找到您的 build.xml 并将“-package-resources”目标替换为以下目标。我很确定(目前无法测试它)您可以在使用 ANT 构建时使用“-Dcompression.disabled=set”或在您的系统中使用“compression.disabled=set”来打开和关闭压缩.properties 文件。

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文