versionCode && and build.gradle


#1

hi all,

i have some question about versionCode and build.gradle. I noticed that to version code extra numbers are added if some condition match during the package build. Lets assume that in my case that’s not necessary and i only need to have the “pure” versioncode without any extra number. its safe to edit build.gradle? is there another way to generate a different build.gradle without extra numbers appended to versioncode?

regards,
davide


#2

I have the same problem. It adds a “8” to all my new version of the apk (similar post).

I found the following in the build.gradle file:
def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion") // Vary versionCode by the two most common API levels: // 14 is ICS, which is the lowest API level for many apps. // 20 is Lollipop, which is the lowest API level for the updatable system webview. if (minSdkVersion >= 20) { defaultConfig.versionCode += 9 } else if (minSdkVersion >= 14) { defaultConfig.versionCode += 8 }

Apparently that’s the problem, does anyone know because it changes the version in the config.xml? What problem would bring change it?


#3

i’ve solved this by creating a new file build-extras.gradle with

`android {

   cdvVersionCode = "yourversioncode"
   lintOptions {
     
      disable 'MissingTranslation'
      disable 'ExtraTranslation'

  }


}

Doing this you basically overwrite the “automatic” version code system and you are able to avoid extra numbers. I also added the lintOptions because i got some problem in build --release phase. Perhaps you may find this usefull for your project.

BestRegards,
Davide