Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

android - Documentation for aapt element in Ant script

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 executable="${aapt}"

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?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I couldn't find anything and ended up using the following which seems to work

    <exec executable="${aapt}" failonerror="true">
      <arg value="package" />
      <arg value="-f" />
      <arg value="-v" />
      <arg value="-M" />
      <arg path="AndroidManifest.xml" />
      <arg value="-A" />
      <arg path="assets" />
      <arg value="-I" />
      <arg path="${android.jar}" />
      <arg value="-m" />
      <arg value="-J" />
      <arg path="${out.absolute.dir}" />
      <arg value="-F" />
      <arg path="${out.absolute.dir}/${resource.package.file.name}" />
      <arg value="-S" />
      <arg path="res" />
      <arg value="--rename-manifest-package" />
      <arg value="my.new.package.name" />
    </exec>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...