Skip to content

[Android] Not specifying the flavor does not let Flutter exit early when building. #139286

@navaronbracke

Description

@navaronbracke

Is there an existing issue for this?

Steps to reproduce

  1. flutter create flavor_sample
  2. Add productFlavors in app/build.gradle. See the code sample.
  3. Run the app on an Android device with flutter run
  4. The process terminates with an error.
  5. Now run flutter run --flavor=<name> and provide the name of a flavor.
  6. The app is built correctly.

Expected results

The flutter run invocation should exit early with a tool exit.

See also the discussion in #96514

Actual results

The tool encounters an exception, as seen in the logs.

Code sample

Code sample
    flavorDimensions "app"
    productFlavors {
        "dev" {
            applicationId = "com.example.flavor_sample_dev"
        }

        "production" {
            applicationId = "com.example.flavor_sample"
        }
    }

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
navaronbracke@MacBook-Pro-van-Navaron flavor_sample % flutter run
Launching lib/main.dart on motorola one in debug mode...
Running Gradle task 'assembleDebug'...                             67.8s
Exception: Gradle build failed to produce an .apk file. It's likely that this file was generated under /Users/navaronbracke/Desktop/flavor_sample/build, but the tool couldn't find it.
navaronbracke@MacBook-Pro-van-Navaron flavor_sample % flutter run --flavor=dev
Launching lib/main.dart on motorola one in debug mode...
Running Gradle task 'assembleDevDebug'...                          16.5s
✓  Built build/app/outputs/flutter-apk/app-dev-debug.apk.
Installing build/app/outputs/flutter-apk/app-dev-debug.apk...        26.3s
Syncing files to device motorola one...                             80ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on motorola one is available at: http://127.0.0.1:52545/0hHyXTeHQLg=/
The Flutter DevTools debugger and profiler on motorola one is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:52545/0hHyXTeHQLg=/
W/Gralloc3(14914): mapper 3.x is not supported

Application finished.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.0, on macOS 14.0 23A344 darwin-x64, locale
    en-BE)
    • Flutter version 3.16.0 on channel stable at
      /Users/navaronbracke/Documents/flutter
    • Upstream repository [email protected]:navaronbracke/flutter.git
    • FLUTTER_GIT_URL = [email protected]:navaronbracke/flutter.git
    • Framework revision db7ef5bf9f (2 weeks ago), 2023-11-15 11:25:44 -0800
    • Engine revision 74d16627b9
    • Dart version 3.2.0
    • DevTools version 2.28.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/navaronbracke/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.13.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.84.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.76.0

[✓] Connected device (3 available)
    • motorola one (mobile) • ZL5228NFL7 • android-arm64  • Android 10 (API 29)
    • macOS (desktop)       • macos      • darwin-x64     • macOS 14.0 23A344
      darwin-x64
    • Chrome (web)          • chrome     • web-javascript • Google Chrome
      119.0.6045.199

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions