Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'

I am having this problem with my android studio, so anytime I ran the actual default flutter project in android studio it runs. as soon as I add packages in the pubspec.yaml I get errors. I am trying to run a project, this project has been running so well for sometime now. all of a sudden when I come back to the project and run it I get this weird error. I asked ChatGPT and it said it was a jdk incompatibility problem. this is the error.


    Launching lib\main.dart on AOSP on IA Emulator in debug mode...
    Running Gradle task 'assembleDebug'...
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
    > Could not resolve all files for configuration ':path_provider_android: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: C:\Users\Mr. Wolfe\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
             > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\Mr. Wolfe\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\Mr. Wolfe\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\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 9s
    Error: Gradle task assembleDebug failed with exit code 1

this is what my app/build.gradile looks like;


    plugins {
        id "com.android.application"
        id "kotlin-android"
        // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
        id "dev.flutter.flutter-gradle-plugin"
    }
    
    android {
        namespace = "com.example.new_flutter"
        compileSdk = flutter.compileSdkVersion
        ndkVersion = flutter.ndkVersion
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
    
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8
        }
    
        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId = "com.example.new_flutter"
            // You can update the following values to match your application needs.
            // For more information, see: https://flutter.dev/to/review-gradle-config.
            minSdk = flutter.minSdkVersion
            targetSdk = flutter.targetSdkVersion
    //        multiDexEnabled true
            versionCode = flutter.versionCode
            versionName = flutter.versionName
        }
    
        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
                signingConfig = signingConfigs.debug
            }
        }
    }
    
    flutter {
        source = "../.."
    }

like image 978
Fred_Wolfe Avatar asked Jan 23 '26 17:01

Fred_Wolfe


1 Answers

Since last 5 days I have the same issue. It is not related to android studio. I have this issue in VS code as well. Could you find a solution. I couldn't yet. While adding some packages this issue occurs. e.g. give, google fonts, etc.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':path_provider_android: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: C:\Users\aksha\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
         > Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\aksha\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\aksha\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\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 8s
Error: Gradle task assembleDebug failed with exit code 1

I tried creating a new project, and when adding some packages this issue occurs even for counter app.

UPDATE: https://github.com/flutter/flutter/issues/156558

This solved my issue. https://github.com/flutter/flutter/issues/156304#issuecomment-2397707812 What's done here:

Open android/app/build.gradle and change:

 android {
        ndkVersion = "25.1.8937393"
        ...
   
    compileOptions {
      sourceCompatibility JavaVersion.VERSION_17
      targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

Open android/gradle/wrapper/gradle-wrapper.properties and change:

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

Open android/settings.gradle and change:

    id "com.android.application" version "8.3.1" apply false
like image 197
Akshaykumar Avatar answered Jan 25 '26 08:01

Akshaykumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!