Search code examples
flutterhomebrew-cask

Flutter Android Build fails with android.multidex does not exist


I've updated my version of flutter and now my Android build fails. Here is a screen shot of the error I'm getting when I execute: flutter run.

enter image description here

If I try to execute ./gradlew clean on the android project directly, I get

Execution failed for task ':gradle:compileGroovy'. BUG! exception in phase 'semantic analysis' in source unit '/opt/homebrew/Caskroom/flutter/3.22.0/flutter/packages/flutter_tools/gradle/src/main/groovy/app_plugin_loader.groovy' Unsupported class file major version 65

I've tried updating homebrew, but this is still an issue. Any ideas???

Here is my flutter doctor print out, in case it helps.

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0.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 2023.3) [✓] VS Code (version 1.88.0) [✓] Connected device (3 available) [✓] Network resources


Solution

  • Check your gradle file at: android/app/build.gradle

    inside "defaultConfig"

    defaultConfig {
     multiDexEnabled true
    }
    

    and inside "dependencies"

    dependencies {
    implementation 'androidx.multidex:multidex:2.0.0'
    }