skip to Main Content

Whenever I try to run flutter project on android emulator I get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexBuilderDebug'.
> There were multiple failures while executing work items
   > A failure occurred while executing com.android.build.gradle.internal.dexing.DexWorkAction
      > Failed to process: project_path/android/app/build/intermediates/transforms/APMSPlugin/debug/246, project_path/android/app/build/intermediates/transforms/APMSPlugin/debug/247

and many more like this.

The logs also contain many:

Caused by: java.util.concurrent.ExecutionException: com.android.tools.r8.kotlin.H

and

Caused by: [CIRCULAR REFERENCE: com.android.tools.r8.kotlin.H]

flutter doctor –verbose result:

[✓] Flutter (Channel stable, 3.16.4, on macOS 14.1.1 23B81 darwin-arm64, locale en-AE)
    • Flutter version 3.16.4 on channel stable at /Users/hassanmohamed/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2e9cb0aa71 (2 weeks ago), 2023-12-11 14:35:13 -0700
    • Engine revision 54a7145303
    • Dart version 3.2.3
    • DevTools version 2.28.4

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

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

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

[✓] Android Studio (version 2023.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 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Community Edition (version 2022.2.5)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 222.4582

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 12 (API 32) (emulator)
    • iPhone 15 Pro Max (mobile)  • 7F0F134E-A16B-47E6-843D-C265C809FBC4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 120.0.6099.129
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

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

• No issues found!

I tried to update gradle version to 8.2 and 8.5 but it failed to update because of flutter packages.

2

Answers


  1. Chosen as BEST ANSWER

    I found the solution thanks to ChatGPT, just adding minifyEnabled true to buildTypes solved the issue, here is the code:

        buildTypes {
            debug {
                minifyEnabled true
            }
        }
    

  2. Run the following commands in your project directory to clean and rebuild the project:

    flutter clean
    flutter pub get
    flutter run
    

    Update Gradle Version:
    Ensure that you are using a compatible version of Gradle.
    Open the android/build.gradle file and update the gradle version. For example:

    classpath ‘com.android.tools.build:gradle:4.1.0’

    Update Android Gradle Plugin:

    implementation ‘com.android.tools.build:gradle:4.1.0’
    Increase Heap Size:

    android {
        ...
        dexOptions {
            javaMaxHeapSize "4g"
        }
    }
    

    https://www.fiverr.com/jinnat75/do-professional-flutter-mobile-app-development-services

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search