javaandroidfluttergradlesdk

Flutter Build Failed with JdkImageTransform Error during :app:compileDebugJavaWithJavac


I'm a beginner in Flutter and I'm facing an issue while trying to build my app. Here is the error message I encountered:

Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':app:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: /home/user-name/Android/Sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /opt/android-studio/jbr/bin/jlink with arguments {--module-path /home/user-name/.gradle/caches/transforms-3/9263d05e7a9236c2cfa2ca39c5a20e5a/transformed/output/temp/jmod --add-modules java.base --output /home/user-name/.gradle/caches/transforms-3/9263d05e7a9236c2cfa2ca39c5a20e5a/transformed/output/jdkImage --disable-plugin system-modules}

here my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on Ubuntu 24.04.1 LTS 6.8.0-45-generic,
    locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.2)
[✓] Connected device (3 available)
[✓] Network resources


What I've tried so far:

  1. Set JAVA_HOME to Java 17 (/usr/lib/jvm/java-17-openjdk-amd64) and verified it with java -version.
  2. Change Android Studio Ladybug into koala ( same error appear ).
  3. Cleared the Gradle cache using ./gradlew clean and flutter clean, but the issue persists.
  4. Reinstalled Android SDK platform 34 using the Android Studio SDK Manager.

Despite these efforts, I keep running into this error when building the app. I'm not sure what else to try and would really appreciate any guidance or suggestions on how to fix this issue.

Additional Info:

Flutter version: 3.24
Java version: OpenJDK 17
Android Studio version: Android Studio Ladybug
OS: Ubuntu 24

error spsific solutions


Solution

  • You can try the following steps to resolve the build issue:

    id "com.android.application" version "8.7.0" apply false
    
    ndkVersion = "27.0.12077973"
    

    Reference for details : answer