Debugging Bitrise Build Cache for Gradle - Changing the app's version

This help guide is part of the Debugging and optimizing Bitrise Build Cache for Gradle series. We recommend starting there if you haven’t read it yet.

If you change your app’s versionCode or versionName during the the build (e.g. by using the Change Android versionCode and versionName step) don’t do that before running linters, unit tests, etc. Only do it before you produce the actual deployable APK (e.g. right before the Android Build step):

Changing the versionCode or versionName will most likely force the gradle lint and test commands to re-run for the whole project, causing almost 0 cache hit and 0 test avoidance.

This change will not help the steps which are after the Change Android versionCode and versionName step, but the steps before it can properly utilize the build cache.

For a more thorough (but also more complex) solution you can also change your build configuration to read the version code from a plugin, which should help to resolve the issue: