Skip to content

"Enable Android for this project" silently fails if Android is disabled in Flutter config #3552

@DanTup

Description

@DanTup
  • flutter config --no-enable-android
  • Open a Flutter project without an android folder
  • 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:

  1. 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
  2. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions