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
"Enable Android for this project" silently fails if Android is disabled in Flutter config #3552
Click the Device Selector and select "Enable Android for this Project"
This runs flutter create --platforms android . in the background, which completes without error but does not create the android folder and therefore appears to do nothing. Even if you switch to the Output pane to see the output, it's not clear anything went wrong:
[flutter_application_1] flutter create --platforms android --org com.dantup .
Recreating project ....
analysis_options.yaml (created)
Running "flutter pub get" in flutter_application_1... 914ms
Wrote 1 files.
All done!
In order to run your application, type:
$ cd .
$ flutter run
Your application code is in ./lib/main.dart.
exit code 0
Some possible options:
We run flutter config --machine and notice that Android is disabled globally and either
a. Hide the option to enable Android
b. Ask the user if we should enable it globally (by running flutter config --enable-android)
c. Change "Enable Android for this project" to something more specific ("Enable Android globally and configure for this project") and automatically do (b) to enable it
Change Flutter to emit an error when --platforms doesn't match any platforms when filtering out what's disabled (this would result in the error being visible to the user when they run "Enable Android for this project" because it would return an error code)
Note: We need to restart the Daemon after flutter config --enable-android is run. When the user runs it, they are shown "You may need to restart any open editors for them to read new settings" but if we're running it automatically they won't see it.
@csells any opinions on which of these you think would work best?
I think the right answer is for 'flutter create . --platforms' w/ an empty list to return an error. Ideally the VSC plugin would detect that error and offer to reset the config setting.
I think the right answer is for flutter create . --platforms w/ an empty list to return an error
The list isn't empty, it does have android in it, but Flutter silently doesn't create it if that's disabled globally. VS Code doesn't currently know which platforms are disabled globally, although we can use flutter config --machine to find out. I'd usually avoid reading Flutter settings like that (they feel like a detail that Flutter could change and not consider breaking), but I think it improves the UX enough here that it's worth doing (whilst having Flutter reject --platforms android when Android is disabled would prevent the error being silent, it doesn't seem like much of an improvement).
So I'll go with 1a above - I'll leave the "Enable" option as-is, but if selected, check the platform is enabled (and if not, prompt to enable it) before running flutter create. Thanks!
Activity
csells commentedon Sep 8, 2021
I think the right answer is for 'flutter create . --platforms' w/ an empty list to return an error. Ideally the VSC plugin would detect that error and offer to reset the config setting.
DanTup commentedon Sep 8, 2021
The list isn't empty, it does have
androidin it, but Flutter silently doesn't create it if that's disabled globally. VS Code doesn't currently know which platforms are disabled globally, although we can useflutter config --machineto find out. I'd usually avoid reading Flutter settings like that (they feel like a detail that Flutter could change and not consider breaking), but I think it improves the UX enough here that it's worth doing (whilst having Flutter reject--platforms androidwhen Android is disabled would prevent the error being silent, it doesn't seem like much of an improvement).So I'll go with 1a above - I'll leave the "Enable" option as-is, but if selected, check the platform is enabled (and if not, prompt to enable it) before running
flutter create. Thanks!csells commentedon Sep 8, 2021
sgtm