从 2.1 升级到 2.3 时,我遇到了类似的问题,其中内置的“规则”xml 中的符号名称发生了变化。 2.1好像是用ant_rules_3.xml,现在SDK 2.3用main_rules.xml作为起点。如果像我一样,您根据规则文件中的目标自定义了 build.xml,您可能会发现通过创建示例项目重新开始会更容易,如下所述:link text
然后调整 build.xml 以覆盖 main_rules.xml 中列出的部分或全部目标。 (这是在 sdk\tools\ant 文件夹中)。我发现这个过程相当快,而且对于简单的项目,生成的文件可以使用 Ant “开箱即用”。 (对于包含第二个包含 .aidl 文件的源文件夹的项目,我确实必须对 build.xml 进行大量更改,因为 main_rules.xml 无法应对)
main_rules.xml中有两个target引用了aapt,你需要模仿的可能就是这个:
<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>
我认为resourcefilename 是生成的apk 的名称。我的构建脚本生成 apk 并将它们放在 bin 目录中,OK,没有我明确命名资源文件名。
我的 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 中获取它。