1

I tried many options in android/app/build.gradle

but none seems to be working.

for example I tried with below code in default config block

archivesBaseName = "AppName-${versionName}-${new Date().format('yyMMdd')}"

all example seems to be not related to flutter.

Joshi
  • 2,730
  • 5
  • 36
  • 62

3 Answers3

2

You can try this in your gradle file

  buildTypes {
            release {
                signingConfig signingConfigs.debug
                applicationVariants.all { variant ->
                    variant.outputs.all {
                        def appName = "your_app_name_"
                        def buildType = variant.variantData.variantConfiguration.buildType.name
                        def newName
                        if (buildType == 'debug'){
                            newName = "app-${variant.getFlavorName()}-debug.apk"
                        } else {
                            newName = "${appName}${defaultConfig.versionName}_${variant.getFlavorName()}.apk"
                        }
                        outputFileName = newName
                    }
                }
            }
        }
Aia Ashraf
  • 134
  • 5
  • https://stackoverflow.com/questions/62075122/no-such-property-variantconfiguration-for-class – Chris Sep 29 '21 at 15:47
1

This code works with regular builds and flavors.

Add it in the build.gradle (the source is https://stackoverflow.com/a/58392819/7198006)

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        def builtType = variant.buildType.name
        def versionName = variant.versionName
        def versionCode = variant.versionCode
        def flavor = variant.flavorName
        outputFileName = "app-${flavor}-${builtType}-${versionName}-${versionCode}.apk"
    }
}

enter image description here

awaik
  • 10,143
  • 2
  • 44
  • 50
0

enter image description here

You can open pubspec.yaml and search on version and edit it

Version: 1.0.0+1

Dharman
  • 30,962
  • 25
  • 85
  • 135
Aia Ashraf
  • 134
  • 5