After lots of digging i found the solution how i can rename my application package. It's working great.
There are two different ways. The one via arg params:
<!-- Replaces the target in tools\ant\build.xml -->
<target name="-package-resources" depends="-crunch">
<!-- this exec replicates the output of the aapt task in build.xml
-package-resources with the addition of a rename-manifest-package option. -->
<exec executable="${aapt}" failonerror="true">
<arg value="package" />
<arg value="-f" />
<arg value="--auto-add-overlay" />
<arg value="-M" />
<arg path="${basedir}/AndroidManifest.xml" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />
<arg value="-S" />
<arg path="${basedir}/${android.library.reference.1}/${resource.dir}" />
<arg value="-A" />
<arg path="${asset.absolute.dir}" />
<arg value="-I" />
<arg path="${android.jar}" />
<arg value="-F" />
<arg path="${out.absolute.dir}/${resource.package.file.name}" />
<arg value="--rename-manifest-package" />
<arg value="${package.manifest.name}" />
</exec>
</target>
or the direct one (like the original build.xml does):
<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="${package.manifest.version.code}"
versionname="${package.manifest.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}"
manifestpackage="${package.manifest.name}">
<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>
The problem now is that a library i use can't find it's ressources (it's a lib, and i had to include the graphics in my app). So the ressources are in my apps res dir.
The same thing also happens if i try to load a specific ressources (dynamically) from my package. I used ctx.getApplicationPackage() to get the packagename. As long as i use this method it was not working for the renamed version, but as soon as i tried it hardcoded with the package name of the main app it works.
So i assume the references don't updated. Let's say i have app 1 with package com.package.appfinal and app 2 with com.package.apptest. The ressources are still found in com.package.appfinal.
I hope someone has an idea how i can extend the rename process so the ressources are also updated? (or their references)
Thanks in advance.
Cheers, -- Mike