Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Support build of multiple BuildTypes

I've created 3 buildTypes at my android project:

buildTypes {
        release {
            signingConfig signingConfigs.release
            resValue "string", "app_name", "AppName"
        }
        debug {
            applicationIdSuffix ".debug"
            resValue "string", "app_name", "AppName - DEV"
        }
        staging {
            initWith release
            matchingFallbacks = ['release']
            applicationIdSuffix ".debug"
        }
    }

I would like to assemble my staging build type, so I ran "flutter build apk --staging", but flutter can't find that option:

Could not find an option named "staging".

Seems that Flutter build apk command "flutter build apk" supports only 3 types : debug, profile, release; and in case of using custom buildType - there's no support for that.

Is it possible to build an apk of custom BuildType?

like image 679
Juvi Avatar asked Oct 27 '25 02:10

Juvi


2 Answers

I ended up using productFlavors:

flavorDimensions 'app'


productFlavors {
        dev {
            dimension "app"
            resValue "string", "app_name", "AppName - DEV"
            applicationIdSuffix ".debug"
        }
        staging {
            dimension "app"
            resValue "string", "app_name", "AppName - DEV"
            applicationIdSuffix ".debug"
        }
        prod {
            dimension "app"
            resValue "string", "app_name", "AppName"
        }
    }
like image 188
Juvi Avatar answered Oct 28 '25 17:10

Juvi


One solution is to use Android's own Gradle build tasks instead of using Flutter commands.

  1. cd android/
  2. ./gradlew app:build

Then after a succesfull build you should be able to find an apk for each buildType in build/app/outputs/apk/.

like image 29
Kristian Klüver Avatar answered Oct 28 '25 17:10

Kristian Klüver



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!