简体   繁体   中英

different location of AndroidManifest.xml

i have a custom buildchain for an android project. there is a build.xml and build.properties. build.properties contains this line:

manifest.file =${env.WORK_FOLDER}/AndroidManifest.xml

and WORK_FOLDER is correctly set to proj_root_work .

the layout is like the following:

proj_root-_work [DIR] (some stuff gets preprocessed and all finally copied here - src, res, assets and the AndroidManifest.xml)
         -build.xml 
         -build.properties

then i call ant for my build configuration from the proj_root and it complains about not finding AndroidManifest.xml . when i put it in my proj_root it works, but i really want it in my _Work directory. i read that the file HAS TO BE in the root, what is the point then of the build.properties entry? also i saw some custom parameters to aapt.exe ...

any hints welcome, thx

You can give ant instructions to use an alternate AndroidManifest.xml location by using a definition given to aapt during the build, eg "app_manifest":

ant -Dapp_manifest=_Work/AndroidManifest.xml

Then, add the following block to build.xml:

    <target name="-package-resources" depends="-crunch">
    <!-- only package resources if *not* a library project -->
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <aapt executable="${aapt}"
                command="package"
                versioncode="${version.code}"
                versionname="${version.name}"
                debug="${build.is.packaging.debug}"
                manifest="${app_manifest}"
                assets="${asset.absolute.dir}"
                androidjar="${android.jar}"
                apkfolder="${out.absolute.dir}"
                nocrunch="${build.packaging.nocrunch}"
                resourcefilename="${resource.package.file.name}"
                resourcefilter="${aapt.resource.filter}"
                projectLibrariesResName="project.libraries.res"
                projectLibrariesPackageName="project.libraries.package"
                previousBuildType="${build.last.target}"
                buildType="${build.target}">
            <res path="${out.res.absolute.dir}" />
            <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>
    </do-only-if-not-library>
</target>

This will resolve "app_manifest" to whatever you give it.

I just simply put

<property name="manifest.file" value="AndroidManifest.xml.tmp" />

in the build.xml, below this line

<property file="local.properties" />

and it works well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM