Last active Aug 17, 2018

Incrementing Android Version Documentation

Setup

Step One

Append the following version variable definitions to your app's build.gradle file, this can be anywhere but preferably at the top of the file above all "apply" declarations. You may set the values to your current build/version codes if this is not a new project.

Step Two

In your gradle's default config, update the versionCode and versionName to use the variables declared in the gradle file. This is also where you can make changes to how your version name is displayed (the example below uses the major.minor.patch format), and you can also reuse the variables for example providing a versionName in a release configuration that omits the patch value.

Step Three

Include the increment_android_version_code and increment_android_version_code actions in your fastlane file, providing them both with the path to your app's build.gradle file, and providing the version name value to update to the increment_android_version_name action.

Step Four (Optional)

To commit the version bump to git, simply add your build.gradle path to the default FastLane "git_commit" command.

Available Actions

increment_android_version_code

increment_android_version_code(path: "app/build.gradle")

Increments the "VERSION_BUILD" value in the build.gradle file by one and sets the SharedValues::ANDROID_VERSION_CODE lane context variable.

increment_android_version_name

Increments the version name value in the build.gradle file, the specific value to be updated (major, minor, or patch) is defined by the "type" parameter passed to the method. When updating the major version, the minor and patch values are reset to zero, similarly when updating the minor version, the patch value is reset to zero. This also sets the SharedValues::ANDROID_VERSION_NAME lane context variable.