You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On Android when there are multiple flavors and no --flavor flag is specified then use a default one #22856
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 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.
@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.
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)
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.
Can this be given a higher priority? This is confusing for almost everyone onboarding a project having flavors, especially when iOS behaves differently, and especially when Flutter gives cryptic error messages that doesn't suggest the flavor is missing?
Reacted by Antonio Cansado, TiM, Patt O'Brien, n-kulic, Andre H and Evgen Fil
... especially when Flutter gives cryptic error messages that doesn't suggest the flavor is missing?
Here's the cryptic message in question:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
main.dart:1
Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under /Users/pattobrien/dev/fine_designs/template/src/frontend/build, but the tool couldn't find it.
Exited
This is not a helpful message in the slightest, especially because there is an apk file in that directory, it's just not the name expected.
If a default flavor cannot be selected, then it would be helpful to at least mention what the expected file name is, so that a user can easily spot the difference between the file that does exist vs. the file that the flutter tool is expecting. This seems like a quick win IMO.
Reacted by Marián Hlaváč, TiM, IBRAHIM MOHAMED FOUAD and Evgen Fil
... especially when Flutter gives cryptic error messages that doesn't suggest the flavor is missing?
Here's the cryptic message in question:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
main.dart:1
Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under /Users/pattobrien/dev/fine_designs/template/src/frontend/build, but the tool couldn't find it.
Exited
This is not a helpful message in the slightest, especially because there is an apk file in that directory, it's just not the name expected.
If a default flavor cannot be selected, then it would be helpful to at least mention what the expected file name is, so that a user can easily spot the difference between the file that does exist vs. the file that the flutter tool is expecting. This seems like a quick win IMO.
Does this error mean that it's missing a Flavor name?
Can't the project run by default using flutter run command?
I just bumped into this and with flutter 3.16.x (and gradle 8.2) flutter picks a default flavor (I don't know since which version).
By default gradle sorts the flavor names in alphabetical order and picks the first one. Seems like flutter only supports this.
In Gradle it is possible to mark a flavor as default, but from my tests flutter ignores it:
flavorDimensions=["version"]
productFlavors {
b {
getIsDefault().set(true)
// isDefault true
dimension "version"
}
a {
dimension "version"
}
}
When defining this I would expect b as the default , but when running the app with flutter run then it picks a instead.
Edit: The alphabetical order trick worked randomly only, could not reproduce between two full builds. So I reduce my points to just: the gradle isDefault setting is ignored. So a default flavor is indeed picked, but I can't figure out how to control which one.
> rm -r ./build/app/outputs/flutter-apk
> flutter build apk
..snip..
Gradle build failed to produce an .apk file. It's likely that this file was generated under /path/to/project/build, but the tool couldn't find it.
> ls -la build/app/outputs/flutter-apk
-rw-rw-r-- 1 chase chase 29548328 May 9 20:21 app-dev-release.apk
-rw-rw-r-- 1 chase chase 29548326 May 9 20:21 app-beta-release.apk
-rw-rw-r-- 1 chase chase 29548300 May 9 20:21 app-live-release.apk
Contrarily though, appbundle seems to only produce one.
#147968 will allow users to specify a default-flavor in their pubspec and should be available in the next stable release (whatever comes after 3.22). I believe this satisfies the primary concern/request of this issue.
#139286 tracks the issue of the confusing error message shown when an Android-enabled project has flavors configured but --flavor is not provided.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
matthewcook333 commentedon 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 commentedon Feb 14, 2019
+1 Also face the same issue.
bradyt commentedon 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 commentedon Oct 11, 2019
Also face the same issue. please give a answer this question.
jackyhieu1211-hn commentedon 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)
erabti commentedon May 19, 2020
Any work around for this? This is really needed for us.
msmaromi commentedon May 20, 2020
in vscode you can setup debug configuration
jackyhieu1211-hn commentedon May 20, 2020
@erabti If you use Android Studio. You can try my way.
open Edit Configurations -> build flavor -> enter flavor name (example : develop)
nazdream commentedon 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.
11 remaining items
marianhlavac commentedon Jul 10, 2023
Can this be given a higher priority? This is confusing for almost everyone onboarding a project having flavors, especially when iOS behaves differently, and especially when Flutter gives cryptic error messages that doesn't suggest the flavor is missing?
pattobrien commentedon Aug 2, 2023
Here's the cryptic message in question:
This is not a helpful message in the slightest, especially because there is an apk file in that directory, it's just not the name expected.
If a default flavor cannot be selected, then it would be helpful to at least mention what the expected file name is, so that a user can easily spot the difference between the file that does exist vs. the file that the flutter tool is expecting. This seems like a quick win IMO.
vietstone-ng commentedon Aug 8, 2023
Please support this
giljulio commentedon Aug 16, 2023
Not a default, but if you rather make the issue more explicit - you can use the following code to fail the build when it's not specified
SilenceCodder commentedon Oct 7, 2023
Does this error mean that it's missing a Flavor name?
Can't the project run by default using
flutter runcommand?slaci commentedon Feb 12, 2024
I just bumped into this and with flutter 3.16.x (and gradle 8.2) flutter picks a default flavor (I don't know since which version).
By default gradle sorts the flavor names in alphabetical order and picks the first one. Seems like flutter only supports this.In Gradle it is possible to mark a flavor as default, but from my tests flutter ignores it:
When defining this I would expect
bas the default, but when running the app withflutter runthen it picksainstead.Edit: The alphabetical order trick worked randomly only, could not reproduce between two full builds. So I reduce my points to just: the gradle
isDefaultsetting is ignored. So a default flavor is indeed picked, but I can't figure out how to control which one.ChaseGuru commentedon May 10, 2024
Why setting a default doesn't work
Flutter seems to by default do all flavors.
Contrarily though, appbundle seems to only produce one.
flutter run also fails for me without a flavor
hasanm08 commentedon May 11, 2024
can you please merge this PR? #147968
add `default-flavor` field to flutter pubspec, which will be used as …
document default flavor (#10642)
andrewkolos commentedon May 22, 2024
#147968 will allow users to specify a
default-flavorin their pubspec and should be available in the next stable release (whatever comes after 3.22). I believe this satisfies the primary concern/request of this issue.#139286 tracks the issue of the confusing error message shown when an Android-enabled project has flavors configured but
--flavoris not provided.add `default-flavor` field to flutter pubspec, which will be used as …
github-actions commentedon Jun 5, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.