ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Quick Tip: Auto-generate your versionCode

Andre Perkins
ProAndroidDev
Published in
1 min readSep 27, 2017

The “one click build” is a golden standard that developers would love to achieve. Whether it is making debug builds, builds for QA and especially release builds, the simpler the release process the better. Some even consider it a criterion to measure the health of a codebase by. And the reasoning for this is straightforward. Less steps equate to less time and, more importantly, less chance of error. One easy way to reduce the amount of steps when making a release build in Android is to use the power of the gradle build system to autogenerate the versionCode for your build.

Achieving this is simple. Define the version information for your build and use gradle to generate suitable sting and int values for the versionName and versionCode, respectively.

Here is a simple build.gradle that captures this idea:

Save time and reduce the possibility of mistakes by removing steps (no matter how trivial) from your build process.

All the cool kids are doing it. :)

Do you have some awesome build tips of your own? If so, then please feel free to reach out to me and share!

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Andre Perkins

Android Developer, Television Enthusiast, Bad Joke Connoisseur | @Muru | New York, NY

Responses (2)

Write a response