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

On Android when there are multiple flavors and no --flavor flag is specified then use a default one #22856

Open
tudor07 opened this issue Oct 9, 2018 · 17 comments
Labels
new feature P6 t: gradle tool

Comments

@tudor07
Copy link

tudor07 commented Oct 9, 2018

On Android, when there are multiple flavors defined, and the user runs the app but does not specify a value for the --flavor flag then the following error is shown:

You must specify a --flavor option to select one of them.

This is implemented like that here: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle.dart#L342

This makes it so that everytime we have to specifiy a value for --flavor.
I would propose when the flag is not specified to just default to the first one.
This will make it faster to start your Flutter app, not having to write --flavor _flavor_ everytime.

@zoechi zoechi added tool t: gradle labels Oct 9, 2018
@zoechi zoechi added this to the Future milestone Oct 9, 2018
@zoechi zoechi added the new feature label Oct 9, 2018
@matthewcook333
Copy link

matthewcook333 commented Dec 7, 2018

Also running into this issue, it is a pain to not be able to just run with default commands. Would be nice to have a default flavor.

@royorange
Copy link

royorange commented Feb 14, 2019

+1 Also face the same issue.

@bradyt
Copy link

bradyt commented Aug 19, 2019

@cmwarrington, do you know if flutter should be able to move forward on this? I saw your involvement at the following commits, and made a naive guess you might have an idea for this.

@mewadaArvind
Copy link

mewadaArvind commented Oct 11, 2019

Also face the same issue. please give a answer this question.

@jmagman jmagman added this to Awaiting triage in Tools - Gradle review Jan 10, 2020
@jackyhieu1211-hn
Copy link

jackyhieu1211-hn commented Mar 4, 2020

Hello. I have the same problem.
I fixed it the following way
I use Android Studio.
open Edit Configurations -> build flavor -> enter flavor name (example : develop)

@jonahwilliams jonahwilliams moved this from Awaiting triage to Engineer reviewed in Tools - Gradle review Mar 18, 2020
@erabti
Copy link

erabti commented May 19, 2020

Any work around for this? This is really needed for us.

@msmaromi
Copy link

msmaromi commented May 20, 2020

in vscode you can setup debug configuration

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter Dev",
            "request": "launch",
            "args": ["--flavor", "development"],
            "type": "dart"
        }
    ]
}

@jackyhieu1211-hn
Copy link

jackyhieu1211-hn commented May 20, 2020

@erabti If you use Android Studio. You can try my way.
open Edit Configurations -> build flavor -> enter flavor name (example : develop)

@kf6gpe kf6gpe added the P6 label May 29, 2020
@kf6gpe kf6gpe removed this from the Future milestone Jun 1, 2020
@nazdream
Copy link

nazdream commented Apr 13, 2021

Does anybody know how to set default flavor in Bitrise? I am getting the same error when Bitrise is trying to build the app, and I can't find a way to set flavor.

@jackyhieu1211-hn
Copy link

jackyhieu1211-hn commented Apr 14, 2021

@nazdream
--debug --flavor develop -t lib/main_develop.dart

Try it

@nashihu
Copy link

nashihu commented Sep 16, 2021

I'm looking forward until it solved..

@bobatsar
Copy link

bobatsar commented Sep 23, 2021

I have the same issue and tried the suggested solution in
https://stackoverflow.com/a/60197203/3607358
which references the bug https://issuetracker.google.com/issues/36988145

but I cant make it work. Does anybody know how to use this with flutter?

This is especially annoying when using tests e.g. widgetTests. Every time I want to run a test it needs the --flavor flag

@jackyhieu1211-hn
Copy link

jackyhieu1211-hn commented Sep 23, 2021

@bobatsar
If you use Android studio. Try it.
Screen Shot 2021-09-23 at 15 22 29

@bobatsar
Copy link

bobatsar commented Sep 23, 2021

@hieuseesaa for sure I can provide the flavor e.g. in Android Studio or via commandline but I would like that gradle chooses a default one if none is specified.

@nashihu
Copy link

nashihu commented Oct 26, 2021

in vscode you can setup debug configuration


{

    // Use IntelliSense to learn about possible attributes.

    // Hover to view descriptions of existing attributes.

    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387

    "version": "0.2.0",

    "configurations": [

        {

            "name": "Flutter Dev",

            "request": "launch",

            "args": ["--flavor", "development"],

            "type": "dart"

        }

    ]

}

i'm following @msmaromi alternative for now. it is also possible to share run configuration via git in android studio.

but still better if flutter provide default flavor though

i wonder if next flutter-new-project-template will be provided by flavor both in iOS and android (?)

@aismaniotto
Copy link

aismaniotto commented Mar 9, 2022

+1

@mrRedSun
Copy link

mrRedSun commented Jul 12, 2022

Also agree to this one, would be nice if the default flavor could be specified as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature P6 t: gradle tool
Projects
Tools - Gradle review
  
Engineer reviewed
Development

No branches or pull requests