开发者

aapt basename attribute

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}" o开发者_如何学JAVAutfolder="${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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜