I have been programming an Android App for a while and we want to release two version of it that have minor changes from one another. I am worried about the maintenance of the app once we spilt it into two (I change something in one and don’t update it in the other). What is the best way to go about this? I was thinking of creating two svn branches for each version of the app and having people commit changes to the trunk and then merge them into the branches? Is this the easiest and time effective solution?
Share
Learn to use ant.
http://developer.android.com/guide/developing/projects/projects-cmdline.html
As a basic example, you can generate a build.xml file from command line, inside project directory with
Then you can make a config directory and store some items in there such as the AndroidManifest.xml and a Config.java that you keep in your package. Replace certain items with tokens, for example, build-appone.properties might read
and your files in config will have tokens replacing original text like, Config.java
Then you can edit your build.xml and add custom targets like so
then you can build the target release-appone by either running
or by right clicking build.xml, Run As -> 2. Ant Task …, followed by selecting your target and hitting the run button.
More information can be found on ant in the interwebs.
AndroidManifest.xml
Worth mentioning that if you’re going to move package name, version code, and version name into a build.properties file and copy it over to the root directory using filters from config/AndroidManifest.xml, you need to account for differing package names. So no relative paths to activities in manifest and you’ll also need to customize the -pre-compile target to move the generated R.java to the correct directory (based on package name) and use the ant regex bit to fix package name in R.java, where -pre-compile is an already existing empty target set aside for your use by google
Updating R.java
To update R.java, you want to override the -pre-compile target, locate R.java, move the file, and use replaceregexp to edit the package name inside of the file appropriately. You can lookup documentation for each ant call to customize to your needs. Here’s an example that may contain errors with some comments on relevant portions for further reading in ant documentation.
You’ll need to adapt this to your own circumstances of course.