Since I updated the Android Studio to Android Studio Ladybug | 2024.2.1, some of my projects in Flutter have stopped working. The error was:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_plugin_android_lifecycle:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':flutter_plugin_android_lifecycle: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: <path>\Android\sdk\platforms\android-34\core-for-system-modules.jar.
         > Error while executing process <path>\jlink.exe with arguments {--module-path <path>\jmod --add-modules java.base --output <path>\jdkImage --disable-plugin system-modules}

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 35s
Error: Gradle task assembleDebug failed with exit code 1

While researching the problem, I downloaded and installed the latest JDK and updated one of my old Android projects with the new version. The same problem was present. I changed two Gradle files in the Android directory to fix this.

The first file to fix is “settings.gradle”. In the section “plugins”, change the row containing “com.android.application” with:

id "com.android.application" version "8.3.2" apply false

The second file is “gradle-wrapper.properties”, located in “<flutter project path>\android\gradle\wrapper”. The key “distributionUrl”, must look like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip

I wrote this article as an easy fix for the problem. I hope this solution will be as helpful for you as it was for me.

Was this article helpful?