skip to Main Content

I was working on a project and it worked fine on an emulator, but every time I tried to run it on my phone using live-preview thingy, it threw the error below.

It keeps throwing errors relating to execution failing in JetifyTransform, and arm64 not being transformed to ‘match attributes’

I tried to look up the solutions online and tried various things including:

  • changing the build.gradle file to include lintOptions as suggested on some stack overflow questions
  • running flutter clean and flutter pub get
  • updating the version for kotlin in build.gradle
  • removing the /.gradle folder in /android
  • removing the /cache folder in the global /.gradle folder in C:/Users/XX/.gradle
  • removing the entire C:/Users/XX/.gradle

but nothing so far has worked.

So, to see if the issue stemmed from some dependency I was using, I tried to create a clean project and run it on my phone, but lo and behold. Same error!

I literally just created a project and ran it. Nothing else! And it still threw an error.

This is the error:

Projects $ flutter create bare_flutter
Creating project bare_flutter...
[...]
Your application code is in bare_flutterlibmain.dart.

Projects $ cd .bare_flutter
bare_flutter $ flutter run
Launching libmain.dart on Pixel 6 in debug mode...
Picked up _JAVA_OPTIONS: -Xmx512M

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform arm64_v8a_debug-1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091.jar (io.flutter:arm64_v8a_debug:1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: C:UsersXX.gradlecachesmodules-2files-2.1io.flutterarm64_v8a_debug1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef509117f3c0ac3e0e5cdc13df2596bac1d5e83834815darm64_v8a_debug-1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091.jar.
         > Java heap space
   > Failed to transform x86_64_debug-1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091.jar (io.flutter:x86_64_debug:1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: C:UsersXX.gradlecachesmodules-2files-2.1io.flutterx86_64_debug1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef509177ef080b94d39403b46d649dbecf8178ae61ac1ex86_64_debug-1.0.0-54a7145303f0dd9d0f93424a2e124eb4abef5091.jar.
         > Java heap space
[...]
BUILD FAILED in 26s
Running Gradle task 'assembleDebug'...                             27.5s
Exception: Gradle task assembleDebug failed with exit code 1

Incase a flutter run --verbose would help, here it is. This is right after I deleted the global /.gradle so there’s info on it being downloaded as well

PS: The error starts from line 2586

https://pastebin.com/YzVxCrWM

Thank you!

EDIT: This is the output for flutter doctor -v

bare_flutter $ flutter doctor -v
[✓] Flutter (Channel stable, 3.16.4, on Microsoft Windows [Version 10.0.22621.2861], locale en-IN)
    • Flutter version 3.16.4 on channel stable at D:devFlutterflutter_windows_3_13_9_stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2e9cb0aa71 (9 days ago), 2023-12-11 14:35:13 -0700
    • Engine revision 54a7145303
    • Dart version 3.2.3
    • DevTools version 2.28.4

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:UsersDhruvAppDataLocalAndroidsdk
    • Platform android-34-ext8, build-tools 34.0.0
    • Java binary at: D:Program FilesAndroidAndroid Studiojbrbinjava
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:Program FilesGoogleChromeApplicationchrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.6)
    • Visual Studio at C:Program FilesMicrosoft Visual Studio2022Community
    • Visual Studio Community 2022 version 17.7.34221.43
    • Windows 10 SDK version 10.0.22621.0

[✓] Android Studio (version 2022.3)
    • Android Studio at D:Program FilesAndroidAndroid Studio
    • 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 version "17.0.6" 2023-01-17

[✓] VS Code (version 1.85.1)
    • VS Code at C:UsersDhruvAppDataLocalProgramsMicrosoft VS Code
    • Flutter extension version 3.78.0

[✓] Connected device (4 available)
    • Pixel 6 (mobile)  • 19121FDF6001DG • android-arm64  • Android 14 (API 34)
    • Windows (desktop) • windows        • windows-x64    • Microsoft Windows [Version 10.0.22621.2861]
    • Chrome (web)      • chrome         • web-javascript • Google Chrome 120.0.6099.110
    • Edge (web)        • edge           • web-javascript • Microsoft Edge 120.0.2210.77

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

• No issues found!

EDIT 2: pubspec.yaml

name: bare_flutter
description: "A new Flutter project."

publish_to: "none"

version: 1.0.0+1

environment:
  sdk: ">=3.2.3 <4.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

2

Answers


  1. Chosen as BEST ANSWER

    It turns out, the error was due to not enough memory being accessible, hence the > Java heap space

    To fix this, I first had to remove _JAVA_OPTIONS from my environment variables which is why it was doing a Picked up _JAVA_OPTIONS: -Xmx512M at the beginning

    The default configuration in the .androidgradle.properties was org.gradle.jvmargs=-Xmx4G which also threw an error, so I had to upgrade this to -Xmx16G and that fixed the error and I was able to build in live mode successfuly!


  2. Inspect your pubspec.yaml file for duplicate entries within the dependencies section. For instance, if you’re utilizing both a barcode scanner and an image picker in your project, be aware that the barcode scanner might already include an image picker internally. This situation can lead to complications, so it’s essential to identify and address any such duplicates.

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