Skip to content

[tool] Omitting --flavor when there are Android productFlavors yields Exception: Unsupported Android Plugin version: {AGP version from android/build.gradle} #99381

@navaronbracke

Description

@navaronbracke

When an Android app has product flavors and the --flavor option is omitted,
Gradle fails with a rather unexpected error.

The Flutter tooling should be able to detect that there are product flavors and that the --flavor option was omitted.
If that is the case, the tool should exit with a better error message.

Steps to Reproduce

  1. Run flutter create bug
  2. Add a product flavor section in app/build.gradle
    flavorDimensions "app"
    productFlavors {
        "dev" {
            applicationIdSuffix = "dev"
        }

       // The flavor name 'test' is forbidden by Gradle.

        "prod" {
           applicationIdSuffix = "prod"
        }
    }
  1. Run the app using flutter run
  2. Gradle fails with Exception: Unsupported Android Plugin version: {AGP version from android/build.gradle}
  3. Run the app using flutter run --flavor={any flavor name}
  4. The app builds and runs correctly.

Expected results: The app runs normally.

Actual results: Gradle fails to build the app.

Logs
Launching lib/main.dart on motorola one in debug mode...
Running Gradle task 'assembleDebug'...                            104.9s
Exception: Unsupported Android Plugin version: 7.0.4.

Flutter Doctor

[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-x64, locale
    en-BE)
    • Flutter version 2.10.2 at /Users/navaronbracke/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 097d3313d8 (11 days ago), 2022-02-18 19:33:08 -0600
    • Engine revision a83ed0e5e3
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
    • Android SDK at /Users/navaronbracke/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2021.1)
    • 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 11.0.11+0-b60-7590822)

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

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.109

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions