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 不再存在。你能告诉我应该用什么代替吗?

4

1 回答 1

1

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.

于 2011-01-22T14:50:13.987 回答