Ant 脚本中 aapt 元素的文档 [英] Documentation for aapt element in Ant script

查看:20
本文介绍了Ant 脚本中 aapt 元素的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Android 构建系统编写一些 Ant 脚本,并且遇到了一个可以调用 aapt 的元素.我看过很多例子

I'm working on some Ant scripts for an Android build system and have come across an element to call aapt. I have seen lots of examples with

exec 可执行文件="${aapt}"

exec executable="${aapt}"

但是来自 main_rules.xml 文件的那些使用不同的格式

but the ones that come out of the main_rules.xml file use a different format

    <aapt executable="${aapt}"
            command="package"
            debug="${build.packaging.debug}"
            manifest="AndroidManifest.xml"
            assets="${asset.absolute.dir}"
            androidjar="${android.jar}"
            apkfolder="${out.absolute.dir}"
            resourcefilename="${resource.package.file.name}"
            resourcefilter="${aapt.resource.filter}">
        <res path="${resource.absolute.dir}" />
        <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
        <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
    </aapt>

我想使用此元素重命名包,但找不到有关如何使用它的任何文档.有谁知道我在哪里可以找到一些?

I would like to rename the package using this element, but cannot find any documentation about how to use it. Does anyone know where I can find some?

谢谢

推荐答案

在新版本的 Android SDK 中,ant 构建脚本的工作方式有所不同.它不会通过 exec 元素直接调用 aapt 命令,而是定义一个合适的任务.后者由java 类com.android.ant.AaptExecTask 实现.这个类只提供了 aapt 命令行选项的一个子集.

In the new(er) version of the Android SDK, the ant build script works in a different way. It does not directly invoke the aapt command via an exec element but rather defines an aapt task. The latter one is implemented by the java class com.android.ant.AaptExecTask. This class only provides a subset of the aapt command line options.

您可以在源 java doc 中找到以下关于 aapt 命令行选项和 ant 参数之间映射的简要说明:

You can find a brief description of the mapping between aapt command line options and the ant parameters below as found in the source java doc:

Aapt Option             Ant Name        Type
---------------------------------------------------------------------------------
path to aapt            executable      attribute (Path)
command                 command         attribute (String)
-v                      verbose         attribute (boolean)
-f                      force           attribute (boolean)
-M AndroidManifest.xml  manifest        attribute (Path)
-I base-package         androidjar      attribute (Path)
-A asset-source-dir     assets          attribute (Path
-S resource-sources     <res path="">   nested element(s)
                                        with attribute (Path)
-0 extension            <nocompress extension="">  nested element(s)
                        <nocompress>               with attribute (String)
-F apk-file             apkfolder                  attribute (Path)  
                        outfolder                  attribute (Path) deprecated
                        apkbasename                attribute (String)
                        basename                   attribute (String) deprecated

-J R-file-dir       rfolder         attribute (Path)
                                    -m always enabled

据我所知,没有办法通过这个新的构建任务提供通用的 aapt 选项.这似乎只有通过修改 SDK 的 build.xml 副本才有可能替换 aapt 调用.

As far as I found out, there is no way to provide the generic aapt options through this new build task. This seems to be possible only by taking a modified copy of the SDK's build.xml with replacements for the aapt invocations.

如果有人知道更好的解决方案,我也很乐意阅读;-)

If anyone knows a better solution, I'd be glad to read about, too ;-)

在更新版本的 SDK 中,再次引入了重命名包:

In even newer versions of the SDK the introduced renaming packages again:

Aapt Option   --rename-manifest-package package-name 
Ant Name      manifestpackage
Type          attribute (String)

这篇关于Ant 脚本中 aapt 元素的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆