When we work in a team projects, our code constantly changes and being tested. Often some bugs occur in a specific version of application and no longer exists in next version of the project, because one programmer might fixed the bug according to the Boy Scout Rule and this is good. Nevertheless, sometimes we need to write documentation and check in which version bug occurred to be sure, that it was really fixed. In addition, QA Engineer needs to know, which version of the project he or she should check.
That’s why we should introduce versioning system to our project. In Android Manifest we have
versionCode is used for updates on Google Play Store and it has to be integer value. We should increment
versionCode before releasing new version of the application for the users. The
versionName available in Android Manifest is a string value and we can use it to store information, which we need in a current project. When we use Git as a Version Control System, we can put SHA value of a specific commit into our version name. In addition, we can add date and time of compilation to this variable. After that, our
versionName contains very detailed information about current version of our application. Exemplary
versionName will look in as follows:
We can obtain that with proper configuration of
build.gradle file containing
buildTime() method and
Please, take a look at creation of
versionName in 35th line of the
build.gradle file presented below.