can not find flutter android version code-ThrowExceptions

Exception or error:

I was able to build the release version of my app and uploaded to play store, Now I want to update it and I need to change the versionCode. However when I look in my <android/app/build.gradle> the part which says version which is supposed to be an integer is now something like flutterVersionCode.toInteger() and versionName flutterVersionName is a bit confusing for me and I dont know where to change it from.

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the file.")

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    throw new GradleException("versionCode not found. Define flutter.versionCode in the file.")

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    throw new GradleException("versionName not found. Define flutter.versionName in the file.")

apply plugin: ''
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'

    defaultConfig {
        // TODO: Specify your own unique Application ID (
        applicationId "com.example.someApp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
        useProguard true

        proguardFiles getDefaultProguardFile('proguard-android.txt'), ''        

flutter {
    source '../..'

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    //implementation ''
    //compile ''
    implementation ''


apply plugin: ''
How to solve:

You don’t need to modify manually your build.gradle.

Open your pubspec.yaml and you will find an entry like this:

version: 1.0.0+1

Flutter uses semantic versioning so what do you need is modify that entry:

version: 1.0.1+2

In this case the version name will be 1.0.1 and the version code will be 2


Go to and change versionName-versionCode


After changing version code , open android part in android studio, generate apk from android studio like native android apk

Leave a Reply

Your email address will not be published. Required fields are marked *