fix errors in test build introduced by renaming the package in AndroidManifest.xml

instead, we can customise the build task to add a manifestpackage parameter to aapt
this will ONLY rename the package according to android package uniqueness - not any other instances (such as the name of the R resource class, relative class names in the manifest file, etc)
see http://stackoverflow.com/a/11084817 and http://www.piwai.info/renaming-android-manifest-package/ for details

(we still have a hacky mobile-test-setup/revert - but only to rename the title string now)
This commit is contained in:
Jon Atkins 2013-08-30 03:50:02 +01:00
parent de3d05fe95
commit 004a34bd29
3 changed files with 42 additions and 8 deletions

View File

@ -2,7 +2,5 @@
# reverse of mobile-test-setup - reverts the changes made to AndroidManifest.xml and any resource files # reverse of mobile-test-setup - reverts the changes made to AndroidManifest.xml and any resource files
mv mobile/AndroidManifest.xml~ mobile/AndroidManifest.xml
mv mobile/res/values/strings.xml~ mobile/res/values/strings.xml mv mobile/res/values/strings.xml~ mobile/res/values/strings.xml

View File

@ -2,14 +2,11 @@
# quick-n-dirty script to rename the mobile build for tests # quick-n-dirty script to rename the mobile build for tests
# rename the package, so it can be installed alongside the regular build
test -f mobile/AndroidManifest.xml~ || cp mobile/AndroidManifest.xml mobile/AndroidManifest.xml~
sed -e 's/package="com.cradle.iitc_mobile"/package="com.cradle.iitc_mobile.test"/' mobile/AndroidManifest.xml~ > mobile/AndroidManifest.xml
# rename the app title # rename the app title
test -f mobile/res/values/strings.xml~ || cp mobile/res/values/strings.xml mobile/res/values/strings.xml~ test -f mobile/res/values/strings.xml~ || cp mobile/res/values/strings.xml mobile/res/values/strings.xml~
sed -e 's/IITC Mobile/IITCm Test/' mobile/res/values/strings.xml~ > mobile/res/values/strings.xml sed -e 's/IITC Mobile/IITCm Test/' mobile/res/values/strings.xml~ > mobile/res/values/strings.xml
# also, you'll need to build with
# ant -Doverride.package.name=com.cradle.iitc_mobile.test ...
# or similar

View File

@ -86,6 +86,45 @@
In all cases you must update the value of version-tag below to read 'custom' instead of an integer, In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project" in order to avoid having your file be overridden by tools such as "android update project"
--> -->
<!-- allow the package name to be overridden when building -->
<property name="override.package.name" value="com.cradle.iitc_mobile"/>
<!-- Puts the project's resources into the output package file
This actually can create multiple resource package in case
Some custom apk with specific configuration have been
declared in default.properties.
-->
<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}"
manifestpackage="${override.package.name}"
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"
libraryRFileRefid="project.library.bin.r.file.path"
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>
<!-- version-tag: 1 --> <!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" /> <import file="${sdk.dir}/tools/ant/build.xml" />