1

Today I noticed that my debug build broke because the BuildConfig.VERSION_NAME now returns

1.6-debug

instead of

1.6

which is how it used to work before. Does anyone know if there's any documentation changes around this change?

If you're building the debug variant, it now appends -debug when you call BuildConfig.VERSION_NAME which is not the case before.
Regardless of whether it's a release or debug build, the value of BuildConfig.VERSION_NAME is always the same.

defaultConfig {
        applicationId "com.myapplication.id"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 106
        versionName "1.6"
        multiDexEnabled true //important
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

buildTypes {
    debug {
        minifyEnabled false
        useProguard false
        debuggable true
        buildConfigField "Boolean", "DEBUG_MODE", "true"
        versionNameSuffix "-debug"
    }
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
joke4me
  • 812
  • 1
  • 10
  • 29

2 Answers2

0

VERSION_NAME is versionName in your build.gradle. Maybe you have multiple build files for different build variants or just append the build variant to your versionName.

georgij
  • 2,054
  • 4
  • 27
  • 43
0

Remove versionNameSuffix "-debug" in your build.gradle file:

buildTypes {
    debug {
        ....
        //versionNameSuffix "-debug"
    }
}

You can check the doc:

Version name suffix. It is appended to the "base" version name when calculating the final version name for a variant.
In case there are product flavor dimensions specified, the final version name suffix will contain the suffix from the default product flavor, followed by the suffix from product flavor of the first dimension, second dimension and so on.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    I had this suffix before and never got two different strings for debug and release builds. Only today when updated my dependecies and did a test run is when I noticed my app broke, I guess there's bug fixes in Android studio? Anyway thanks for your help! – joke4me Sep 09 '19 at 07:23