0

I want to display the current revision number of my Android project to the user. I use the subclipse plugin for Eclipse and already found out that I somehow need the program svnversion.

I've found this answer, but I don't get at all where I have to change what and how I finally access the number to put it into a TextView. Also, I feel a bit sheepish about interfering with the Android build process.

Is there some easier explanation / example out there?

Kind regards, jellyfish

2 Answers 2

1
+50

I would suggest not using the version control for showing version number. Revision numbers and app version are inherently different. You don't want to notch your app version for a spelling fix :-) .

What you can do is set your version name in the manifest to refer a string from values/string.xml . You can then show this string in the app where ever needed.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks that actually solves it, kind of. ;) I will give you the bounty as soon as I'm allowed to by the system. ^^
0

You can get the name and numeric ID that are stored in your manifest with this:

public String getAppVerName() {
    String text;
    try {
        text = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        text = "Version Not Found";
    }
    return text;
}

Replace .versionName; with .versionId; to get the numeric value. I have a write up about this on my blog: http://www.aydabtudev.com/2011/03/android-tracking-version-usage.html

4 Comments

is this really the build number? I keep getting "1.0", no matter how often I commit a new version...
It's the number that's stored in the manifest. That number must be incremented when you publish your app to the market. It does not coincide with the version number in your SVN repository. I misunderstood your question.
Find a way to increment the manifest.xml on submit ... that would be useful ;)
You could try to write an svn hook that increments the versionCode and versionName tags.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.