is there a way to auto-increment the version code each time you build an Android application in Eclipse?
According to http://developer.android.com/guide/publishing/v
Here is the Java version for what it's worth. Also handling multiple manifests.
String directory = "d:\\Android\\workspace\\";
String[] manifests = new String[]
{
"app-free\\AndroidManifest.xml",
"app-donate\\AndroidManifest.xml",
};
public static void main(String[] args)
{
new version_code().run();
}
public void run()
{
int I = manifests.length;
for(int i = 0; i < I; i++)
{
String path = directory + manifests[i];
String content = readFile(path);
Pattern versionPattern = Pattern.compile( "(.*android:versionCode=\")([0-9]+)(\".*)", Pattern.DOTALL );
Matcher m = versionPattern.matcher(content);
if (m.matches())
{
int code = Integer.parseInt( m.group(2) ) + 1;
System.out.println("Updating manifest " + path + " with versionCode=" + code);
String newContent = m.replaceFirst("$1" + code + "$3");
writeFile(path + ".original.txt", content);
writeFile(path, newContent);
}
else
{
System.out.println("No match to update manifest " + path);
}
}
}