I'm trying to set the android:versionName
in my android manifest as a reference to string resource stored in external resource file.
Below is an excerpt from my AndroidManifest.xml
:
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.toycorporation"
android:versionCode="@integer/version_code"
android:versionName="@string/version_name"
>
and the content of build.xml file located under res/values
disrectory of my project:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<item type="string" name="build_date">03/15/2012</item>
<item type="integer" name="version_code">315281</item>
<item type="string" name="version_name">3.15.28.1</item>
</resources>
Later I attempt to retrieve the version number to display it on the About screen of my application.
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(),0);
Log.d("PackageInfo", "Version name: " + String.valueOf(packageInfo.versionName));
Problem description:
When I build the application and automatically install it on my HTC device everything works perfect. Version name gets passed by reference and on the About screen I get version name value logged in the logcat.
But when I attempt to build the application and launch it on the emulator I get null
instead of the version name value.
I have already tried to build and install the app to emulator using Eclipse and IDEA. So it seems the issue is not related to IDE.
UPDATE:
One additional thing appeared which doesn't work with such use of versionName
and versionCode
. Application can not be deployed to the Google Play. The following error appears:
The file is invalid: ERROR getting 'android:versionCode' attribute: attribute is not an integer value