# Android version codes in Gradle build variants and generated configuration

DevFeed: [Android version codes in Gradle build variants and generated configuration](<https://devfeed.tech/articles/android-version-code-tricks-38615.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2019_07_04_android_version_code_tricks/>)

Published: 2019-07-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [version](<https://devfeed.tech/topics/version.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [build tools](<https://devfeed.tech/topics/build-tools.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [build](<https://devfeed.tech/tags/build.md>), [build-tools](<https://devfeed.tech/tags/build-tools.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [version](<https://devfeed.tech/tags/version.md>)

## AI overview

This article explains how Android version codes are configured in build.gradle, accessed through BuildConfig and PackageManager, and overridden for specific build variants. It describes a discrepancy in which BuildConfig.VERSION_CODE and the processed AndroidManifest can receive different values because separate build-tool tasks use different sources.

## Source excerpt

Introduction Version code is a special integer value which works as an internal version number. It is not visible to end users. Android system uses this number to protect against application downgrades -- it is not possible to install new application with version code lower than in currently installed application. Developers can use version code for example for doing specific tasks on updating to specific version. Version code is placed inside AndroidManifest, but usually it is inside *defaultConfig *in build.gradle (from where it is populated to *AndroidManifest *during assemble). Also it is possible to access version code from generated BuildConfig.VERSION_CODE.