This gradle snippet setup auto management of versionCode and versionName using tags found on your git repository.
- When building an apk from a commit tagged
v1.4.2, thenversionNamewill bev1.4.2 - When building an apk from a commit
abcd123which is the 3rd one after tagv1.5.7, thenversionNamewill bev1.5.7-3-gabcd123 versionCodeis automatically handled givenversionNamevalue
Just add a tag in your git repository name like v1.4.2.