aapt 基本名称属性

发布于 2024-10-13 13:12:06 字数 444 浏览 3 评论 0 原文

我将 SDK 升级到 2.3,但我的构建脚本开始失败。我收到此错误:

build.xml:363: aaptexec 不支持“basename”属性

对于我的构建脚本中的以下行:

<aapt executable="${aapt}" command="package" manifest="AndroidManifest.xml" resources="${resource.absolute.dir}" assets="${asset.absolute.dir}" androidjar="${android.jar}" outfolder="${out.absolute.dir}" basename="${ant.project.name}" />

我不知道 aapt 中发生了什么变化,但显然 basename 不再存在。你能告诉我应该用什么来代替吗?

I upgraded my SDK to 2.3 and my build scripts start to fail. I am getting this error:

build.xml:363: aaptexec doesn't support the "basename" attribute

For the following line in my build script:

<aapt executable="${aapt}" command="package" manifest="AndroidManifest.xml" resources="${resource.absolute.dir}" assets="${asset.absolute.dir}" androidjar="${android.jar}" outfolder="${out.absolute.dir}" basename="${ant.project.name}" />

I do not know what changed in aapt but apparently basename is not there any more. Can you tell me what should I use instead?

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

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

发布评论

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

评论(1

灰色世界里的红玫瑰 2024-10-20 13:12:07

当从 2.1 升级到 2.3 时,我遇到了类似的问题,并且内置“规则”xml 中的符号名称发生了变化。 2.1 似乎使用 ant_rules_3.xml,现在 SDK 2.3 使用 main_rules.xml 作为起点。如果像我一样,您已经根据规则文件中的目标自定义了 build.xml,那么您可能会发现通过创建示例项目来重新开始会更容易,如下所示:链接文本

,然后调整 build.xml 以覆盖 main_rules.xml 中列出的部分或全部目标。 (它位于 sdk\tools\ant 文件夹中)。我发现这个过程相当快,对于简单的项目,生成的文件可以“开箱即用”地使用 Ant。 (对于一个包含第二个包含 .aidl 文件的源文件夹的项目,我确实必须对 build.xml 进行大量更改,因为 main_rules.xml 无法处理它)

main_rules 中有两个引用 aapt 的目标。 xml,您可能需要模仿这个:

<target name="-package-resources">
    <echo>Packaging resources</echo>
    <aapt executable="${aapt}"
        command="package"
        versioncode="${version.code}"
        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>
</target>

我认为资源文件名是生成的 apk 的名称。我的构建脚本生成 apk 并将它们放入 bin 目录中,无需明确命名资源文件名。
我的 build.properties 看起来像:(

#-----------------------------------------------
# The ONLY reference to the project's main base
#
projectname=MapProject1.2
#
#-----------------------------------------------

workspace.dir=/dev/projects/EclipseHelios/AndroidWorkspace
ant.project.name=${projectname}
outbasebase.dir=/dev/projects/AntBuilds
base.dir=${workspace.dir}/${projectname}
common_src=/dev/projects/CommonSource121210/GridSeviceAndUseGridService
source.dir=${base.dir}/src
outbase.dir=${outbasebase.dir}/${projectname}

out.dir=${outbase.dir}/bin
key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=*************
key.alias.password=*************
layout.dir=${base.dir}/res/layout

当然除了密码!)

我确实在 buid.xml 中注释掉了项目名称,以便它可以从 build.properties 中获取它。

I had similar problems when upgrading from 2.1 to 2.3 with symbolic names changing in the built in 'rules' xmls. 2.1 seemed to use ant_rules_3.xml, now SDK 2.3 uses main_rules.xml as its starting point. If, like me, you had customised your build.xml based on the targets in the rules file, you will probably find it easier to start again by creating a sample project as described in : link text

then adapting you build.xml to override some or all of the targets that are listed in main_rules.xml. (This is in the sdk\tools\ant folder). I found this process to be reasonably quick, and for simple projects the generated files worked 'out of the box' with Ant. (I did have to change the build.xml a lot for a project which contained a second source folder containing .aidl files, as the main_rules.xml couldn't cope with it)

There are two targets which refer to aapt in the main_rules.xml, it's probably this one that you need to mimic:

<target name="-package-resources">
    <echo>Packaging resources</echo>
    <aapt executable="${aapt}"
        command="package"
        versioncode="${version.code}"
        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>
</target>

I think the resourcefilename is the name of the generated apk. My build scripts generate the apks and put them in the bin directory OK, without my naming the resourcefilename explicitly.
My build.properties looks like:

#-----------------------------------------------
# The ONLY reference to the project's main base
#
projectname=MapProject1.2
#
#-----------------------------------------------

workspace.dir=/dev/projects/EclipseHelios/AndroidWorkspace
ant.project.name=${projectname}
outbasebase.dir=/dev/projects/AntBuilds
base.dir=${workspace.dir}/${projectname}
common_src=/dev/projects/CommonSource121210/GridSeviceAndUseGridService
source.dir=${base.dir}/src
outbase.dir=${outbasebase.dir}/${projectname}

out.dir=${outbase.dir}/bin
key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=*************
key.alias.password=*************
layout.dir=${base.dir}/res/layout

(Apart from the passwords of course!)

I did comment out the projectname in the buid.xml, so that it would pick it up from the build.properties.

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