Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compass_app Build failed with an exception #2558

Open
andreykuzovlevv opened this issue Dec 20, 2024 · 7 comments
Open

compass_app Build failed with an exception #2558

andreykuzovlevv opened this issue Dec 20, 2024 · 7 comments

Comments

@andreykuzovlevv
Copy link

flutter run --target lib/main_development.dart
Launching lib/main_development.dart on sdk gphone64 x86 64 in debug mode...

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\thegr\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\thegr.gradle\caches\transforms-3\25e287933feb4a0b2404987778ffebff\transformed\output\temp\jmod --add-modules java.base --output C:\Users\thegr.gradle\caches\transforms-3\25e287933feb4a0b2404987778ffebff\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 5s
Running Gradle task 'assembleDebug'... 5.7s

┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [!] This is likely due to a known bug in Android Gradle Plugin (AGP) versions less than 8.2.1, when │
│ 1. setting a value for SourceCompatibility and │
│ 2. using Java 21 or above. │
│ To fix this error, please upgrade your AGP version to at least 8.2.1. The version of AGP that your project uses is likely │
│ defined in: │
│ C:\Users\thegr\Desktop\samples\compass_app\app\android\settings.gradle, │
│ in the 'plugins' closure (by the number following "com.android.application"). │
│ Alternatively, if your project was created with an older version of the templates, it is likely │
│ in the buildscript.dependencies closure of the top-level build.gradle: │
│ C:\Users\thegr\Desktop\samples\compass_app\app\android\build.gradle, │
│ as the number following "com.android.tools.build:gradle:". │
│ │
│ For more information, see: │
https://issuetracker.google.com/issues/294137077
flutter/flutter#156304
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1


Gradle 8.11.1

Build time: 2024-11-20 16:56:46 UTC
Revision: 481cb05a490e0ef9f8620f7873b83bd8a72e7c39

Kotlin: 2.0.20
Groovy: 3.0.22
Ant: Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM: 21.0.5 (Oracle Corporation 21.0.5+9-LTS-239)
Daemon JVM: C:\Program Files\Java\jdk-21 (no JDK specified, using current Java home)
OS: Windows 11 10.0 amd64

@ericwindmill
Copy link
Contributor

Can you confirm the AGP version in your settings.gradle file?

@andreykuzovlevv
Copy link
Author

pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}

}

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"

what is AGP here?

@jordipimar
Copy link

i have I have the same error if you have solved it, how did you solve it?

@AnasAthimannil
Copy link

AnasAthimannil commented Jan 2, 2025

I have faced same issue and now i resolved by the following steps.

  1. If your JAVA_HOME path or flutter jdk path not in java 21, set JAVA_HOME or run a command "flutter config --jdk-dir <path_to_jdk>" to set flutter jdk path to Java 21.

  2. Go to setting.gradle and update below versions

From

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

To

    id "com.android.application" version '8.7.3' apply false
  1. Go to gradle>wrapper>gradle-wrapper.properties change Version

From

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

To

    distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
  1. Go to build.gradle(app) change

From

compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
}

To

compileOptions {
        sourceCompatibility = JavaVersion.VERSION_21
        targetCompatibility = JavaVersion.VERSION_21
}

NOW IT WORKS !......

@Pinkisingh13
Copy link

@andreykuzovlevv
This is the line where the AGP (Android Gradle Plugin) version should be specified:

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

@Pinkisingh13
Copy link

@AnasAthimannil getting an issue after using this line: compileOptions { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 }

Error: compileOptions { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 }

This is my app/build.gradle :
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

kotlinOptions {
    jvmTarget = "17"
}

Can you please help me to fic jvmTarget?

@AnasAthimannil
Copy link

AnasAthimannil commented Jan 3, 2025

@Pinkisingh13
Also upgrade Kotlin plugin version & jvm target

1. In build.gradle(app)

kotlinOptions {
    jvmTarget = '21'
}

2. In settings.gradle

From

    id "org.jetbrains.kotlin.android" version "1.8.22" apply false

To

    id "org.jetbrains.kotlin.android" version "2.0.21" apply false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants