I am using ant to make a build system for our android project which has two build targets, Dev and Release.
This involves replacing the default -package-resources
target with my own one in my build.xml. It goes from this:
<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="${out.manifest.abs.file}"
assets="${asset.absolute.dir}"
androidjar="${project.target.android.jar}"
apkfolder="${out.absolute.dir}"
nocrunch="${build.packaging.nocrunch}"
resourcefilename="${resource.package.file.name}"
resourcefilter="${aapt.resource.filter}"
libraryResFolderPathRefid="project.library.res.folder.path"
libraryPackagesRefid="project.library.packages"
previousBuildType="${build.last.target}"
buildType="${build.target}"
ignoreAssets="${aapt.ignore.assets}"
>
<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>
To this :
<target name="-package-resources" depends="-crunch">
<!-- only package resources if *not* a library project -->
<echo message="Packaging resources with ${package.internal} as a package name" />
<do-only-if-not-library elseText="Library project: do not package resources..." >
<exec executable="${aapt}" failonerror="true">
<arg value="package" />
<arg value="-f" />
<arg value="-v" />
<arg value="-M" />
<arg path="${out.manifest.abs.file}" />
<arg value="-A" />
<arg path="${asset.absolute.dir}" />
<arg value="-I" />
<arg path="${project.target.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="${out.res.absolute.dir}" />
<arg path="${resource.absolute.dir}" />
<arg value="--no-crunch" />
<arg value="--rename-manifest-package" />
<arg value="${package.internal}" />
</exec>
</do-only-if-not-library>
</target>
However, when I launch the build, it fails on this step with the following error:
-package-resources:
[echo] Packaging resources with dev.appname.android as a package name
[exec] Found 4 custom asset files in /appname/app/native/android/appname/assets
[exec] Processing raw dir '/appname/app/native/android/appname/res'
[exec] /appname/app/native/android/appname/res/drawable/map_marker.png: error: Duplicate file.
[exec] /appname/app/native/android/appname/bin/res/drawable/map_marker.png: Original is here.
Not sure how to proceed here. My understanding was that the -f
flag should take care of overwriting files.