Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android versionCode not changing #282

Open
MatHeartGaming opened this issue Dec 5, 2024 · 0 comments
Open

Android versionCode not changing #282

MatHeartGaming opened this issue Dec 5, 2024 · 0 comments

Comments

@MatHeartGaming
Copy link

Hi everyone! I finally managed to flavorize my app thanks to @AngeloAvv but now I've bumped into another issues which is only Android related. Basically, the app sees all changes I make code side, of course, but it does not see the versionCode. This always remains stuck to version 64 even though I replaces it everywhere in the project.
I changed it in the pubsbec.yaml:

name: ginevra_distribuzioni
description: "The official Ginevra Distribuzioni app"
publish_to: "none"
version: 1.0.0+67

In the flavorizr.yaml:

flavors:
  prod:
    app:
      name: "Ginevra Distribuzioni"

    android:
      applicationId: "it.matbuompy.ginevra_distribuzioni"
      customConfig:
          versionCode: 67
          minSdkVersion: 28
      firebase:
        config: ".firebase/prod/google-services.json"
    ios:
      bundleId: "it.matbuompy.ginevraDistribuzioni"
      firebase:
        config: ".firebase/prod/GoogleService-Info.plist"
    macos:
      bundleId: "it.matbuompy.ginevraDistribuzioni.dev"
      firebase:
        config: ".firebase/prod/GoogleService-Info.plist"
  dev:
    app:
      name: "Ginevra Distribuzioni Dev"
  
    android:
      applicationId: "it.matbuompy.ginevra_distribuzioni.dev"
      firebase:
        config: ".firebase/dev/google-services.json"
    ios:
      bundleId: "it.matbuompy.ginevraDistribuzioni.dev"
      firebase:
        config: ".firebase/dev/GoogleService-Info.plist"
    macos:
      bundleId: "it.matbuompy.ginevraDistribuzioni.dev"
      firebase:
        config: ".firebase/dev/GoogleService-Info.plist"

And my app gradle build file looks like this:

plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    // END: FlutterFire Configuration
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
def localPropertiesFile = rootProject.file('local.properties')

ext {
    flutterVersionCode = localPropertiesFile.exists() ? new Properties().with { props ->
        localPropertiesFile.withReader('UTF-8') { reader -> props.load(reader) }
        props.getProperty('flutter.versionCode', '1')
    } : '1'

    flutterVersionName = localPropertiesFile.exists() ? new Properties().with { props ->
        localPropertiesFile.withReader('UTF-8') { reader -> props.load(reader) }
        props.getProperty('flutter.versionName', '1.0')
    } : '1.0'

    keystoreProperties = keystorePropertiesFile.exists() ? new Properties().with { props ->
        keystorePropertiesFile.withInputStream { stream -> props.load(stream) }
        props
    } : null
}

android {

    // ----- BEGIN flavorDimensions (autogenerated by flutter_flavorizr) -----
    flavorDimensions += "flavor-type"

    productFlavors {
        prod {
            dimension "flavor-type"
            applicationId "it.matbuompy.ginevra_distribuzioni"
            versionCode 67
            minSdkVersion 28
            versionName "1.0.0"
            resValue "string", "app_name", "Ginevra Distribuzioni"
        }
        dev {
            dimension "flavor-type"
            applicationId "it.matbuompy.ginevra_distribuzioni.dev"
            versionCode 67
            minSdkVersion 28
            versionName "1.0.0"
            resValue "string", "app_name", "Ginevra Distribuzioni Dev"
        }
    }

    // ----- END flavorDimensions (autogenerated by flutter_flavorizr) -----

   namespace = "it.matbuompy.ginevra_distribuzioni"
    compileSdkVersion Math.max(flutter.compileSdkVersion, 34)
    ndkVersion =  "27.0.12077973"

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "it.matbuompy.ginevra_distribuzioni"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk = 28
        targetSdk = flutter.targetSdkVersion
        versionCode = 67
        versionName = "1.0.0"
    }

    signingConfigs {
        release {
            keyAlias = keystoreProperties['keyAlias']
            keyPassword = keystoreProperties['keyPassword']
            storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword = keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.release
            
            minifyEnabled true
            

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    implementation 'com.google.android.play:integrity:1.4.0' // Add this line
    // Add other dependencies if needed
}

configurations.configureEach {
    exclude group: 'com.google.android.gms', module: 'play-services-safetynet'
}

But when I build the appbundle with the command: flutter build appbundle --flavor prod -t lib/main_prod.dart and then I upload it to Play Console I get this error:
Screenshot 2024-12-05 at 14 19 43

It seems like the versionCode is not being changed. This only affects Android by the way. iOS and web builds increment their build numbers correctly. How can I solve this on Android?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant