I know that the application version is defined in the manifest xml file, but is there any tool to set the version number in Ecli开发者_如何学Cpse, without manually changing the manifest itself? Thanks.
I use an ant script and xmltask to update the build number in my manifest. This is the target:
<target name="update.build.number">
<xmltask source="AndroidManifest.xml" dest="AndroidManifest.xml">
<replace path="manifest/@android:versionName"
withText="1.0.${buildnum}"/>
</xmltask>
</target>
This sets the version name to 1.0.xxx where xxx is passed into ant in the buildnum property. You could just as easily update the version number instead. If you can come up with a way to create and increment a build number this should be easy to adapt.
It depends on how you define 'manually'.
If you double click the AndroidManifest.xml file in eclipse (and you have your environment set up properly), you should get a GUI with all of the options you can select. One of them on the leftmost tab is to change the version number, both the version name, and the version code.
Edit: To be more precise:
- Open the GUI AndroidManifest.xml editor.
- Click on the Manifest Tab
- In Manifest General Attributes you should see version code and version name.
I did my own Java tool to do. Available here: android manifest build number
Features:
- versionName is supposed to be major.minor.point (as advised by Android doc)
- versionName can be preserved, reset to 1.0.0, or incremented (one single part of it and trailing part(s) is/are set to 0)
- versionCode will be replaced by Unix Time
Hope this help :-)
精彩评论