day_dreamer
day_dreamer

Reputation: 834

Exception: Unsupported Android Plugin version: 4.2.1. when flutter run --release

I am using the latest flutter stable version , flutter doctor -v as below:

    [✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-IN)
    • Flutter version 2.2.2 at /Users/daydreamers/Documents/development/flutter
    • Framework revision d79295af24 (2 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/daydreamers/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/daydreamers/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.1

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 4.2)
    • 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.8+10-b944.6916264)

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

[✓] Connected device (1 available)

I am having Kotlin code for Android and Kotlin version is

ext.kotlin_version = '1.5.20'

I have this in my dependencies :

classpath 'com.android.tools.build:gradle:4.2.1'

I get an error when running flutter run --release, but flutter run works fine.

Exception: Unsupported Android Plugin version: 4.2.1.

I have tried other Answers from SO like updating the JVM version for Kotlin target VM (I set it to 11 from 8) .

I also have distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip in gradle-wrapper.properties.

Any help is greatly appreciated.

Upvotes: 4

Views: 4597

Answers (2)

TheFabbius
TheFabbius

Reputation: 447

I had a similar problem when building with flutter build apk --flavor my_flavor.
I had configured ABI splits in my app build.gradle, and removing them solved the issue since they weren't necessary in my case.

Upvotes: 0

flamyoad
flamyoad

Reputation: 565

See whether there is something like below in your app build.gradle (app/src/build.gradle)

    productFlavors {
        app_dev {
            dimension "version"
            applicationIdSuffix ".dev"
        }
        app_stg {
            signingConfig signingConfigs.debug
            dimension "version"
            applicationIdSuffix ".stg"
        }
        app_prod {
            signingConfig signingConfigs.release
            dimension "version"
        }
    }

If it does have something like that, then you need to go to Run -> Edit Configuration -> Pick your main.dart on left side -> Inside 'Build flavor' put "app_dev" inside the textbox (The string can be anything and it depends on what's inside your productFlavors { ... })

This helped me solve my issue.

Upvotes: 6

Related Questions