gpt4 book ai didi

android - 是否可以使用 build.xml 将未压缩的特定文件添加到 Android APK?

转载 作者:太空狗 更新时间:2023-10-29 13:35:18 26 4
gpt4 key购买 nike

有谁知道在使用 build.xml 的 ANT 构建过程中是否可以将未压缩的特定文件添加到 Android APK 文件中?我的所有文件都位于 assets 文件夹中,并使用相同的扩展名。我确实意识到我可以为我不想添加压缩和指定的文件使用不同的扩展名,例如:

<nocompress extension="NoCompress" />

但这目前不适合我。

我尝试在 build.xml 的 package-resource 部分中的 appt package 步骤之后添加我自己的 aapt add 步骤:

<exec executable="${aapt}" taskName="add">
<arg value="add" />
<arg value="-v" />
<arg value="${out.absolute.dir}/TestAndroid.ap_" />
<arg value="${asset.absolute.dir}/notcompressed.and" />
</exec>

确实将文件添加到 APK,但它被压缩了。 :)

这是可能的还是使用不同的扩展名是唯一的方法?

谢谢!

最佳答案

看看here

The only way (that I’ve discovered, as of this writing) to control this behavior is by using the -0 (zero) flag to aapt on the command line. This flag, passed without any accompanying argument, will tell aapt to disable compression for all types of assets. Typically you will not want to use this exact option, because for most assets, compression is a desirable thing. Sometimes, however, you will have a specific type of asset (say, a database), that you do not want to apply compression to. In this case, you have two options.

First, you can give your asset file an extension in the list above. While this does not necessarily make sense, it can be an easy workaround if you don’t want to deal with aapt on the command line. The other option is to pass a specific extension to the -0 flag, such as -0 db, to disable compression for assets with that extension. You can pass the -0 flag multiple times, and each time with a separate extension, if you need more than one type to be uncompressed.

Currently, there is no way to pass these extra flags to aapt when using the ADT within Eclipse, so if you don’t want to sacrifice the ease of use of the GUI tools, you will have to go with the first option, and rename your file’s extension.

关于android - 是否可以使用 build.xml 将未压缩的特定文件添加到 Android APK?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11276112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com