3

I keep getting this warning on (Fedora) Linux when opening a Flutter project of mine inside VS Code. I changed JAVA_HOME and used flutter config --jdk-dir="/usr/lib/jvm/java-24-openjdk/ to change my Java version but it still keeps coming up with a warning referencing OpenJDK 21 (so before we even get to the question of the right java version, why is it stuck on version 21?):

The supplied phased action failed with an exception.
Could not create task ':app:compileDebugAndroidTestJavaWithJavac'.
Failed to calculate the value of task ':app:compileDebugAndroidTestJavaWithJavac' property 'javaCompiler'.
Toolchain installation '/usr/lib/jvm/java-21-openjdk' does not provide the required capabilities: [JAVA_COMPILER]

I even added org.gradle.java.home=/usr/lib/jvm/java-24-openjdk to android/gradle.properties.

This is the output of flutter doctor --verbose:

[✓] Flutter (Channel stable, 3.32.6, on Fedora Linux 41 (KDE Plasma) 6.15.5-100.fc41.x86_64, locale en_GB.UTF-8) [120ms]
    • Flutter version 3.32.6 on channel stable at /home/bitmapp3r/dev/flutter-sdk
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 077b4a4ce1 (6 days ago), 2025-07-08 13:31:08 -0700
    • Engine revision 72f2b18bb0
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,977ms]
    • Android SDK at /home/bitmapp3r/Android/Sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /usr/lib/jvm/java-17-openjdk/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (Red_Hat-17.0.15.0.6-1) (build 17.0.15+6)
    • All Android licenses accepted.

[✓] Chrome - develop for the web [25ms]
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop [556ms]
    • clang version 19.1.7 (Fedora 19.1.7-4.fc41)
    • cmake version 3.30.8
    • ninja version 1.12.1
    • pkg-config version 2.3.0
    • OpenGL core renderer: AMD Radeon Graphics (radeonsi, renoir, ACO, DRM 3.63, 6.15.5-100.fc41.x86_64)
    • OpenGL core version: 4.6 (Core Profile) Mesa 25.0.7
    • OpenGL core shading language version: 4.60
    • OpenGL ES renderer: AMD Radeon Graphics (radeonsi, renoir, ACO, DRM 3.63, 6.15.5-100.fc41.x86_64)
    • OpenGL ES version: OpenGL ES 3.2 Mesa 25.0.7
    • OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
    • GL_EXT_framebuffer_blit: yes
    • GL_EXT_texture_format_BGRA8888: yes

[✓] Android Studio (version 2025.1.1) [21ms]
    • Android Studio at /opt/android-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 Runtime Environment (build 21.0.6+-13391695-b895.109)

[✓] VS Code (version unknown) [19ms]
    • VS Code at /usr/share/code
    • Flutter extension version 3.114.0
    ✗ Unable to determine VS Code version.

[✓] Connected device (3 available) [261ms]
    • SM S911B (mobile) • RFCX808ZYCE • android-arm64  • Android 15 (API 35)
    • Linux (desktop)   • linux       • linux-x64      • Fedora Linux 41 (KDE Plasma) 6.15.5-100.fc41.x86_64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 138.0.7204.100

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

• No issues found!

Here is my android/app/build.gradle.kts (I omitted the project name)

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.x"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

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

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.x"
        // 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
        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.getByName("debug")
        }
    }
}

flutter {
    source = "../.."
}
8
  • What Flutter version are you using? Also, could you share the build.gradle of your project? Commented Jul 15 at 4:38
  • @tomerpacific I just added the output of flutter doctor --verbose which should include the Flutter version, along with my android/app/build.gradle.kts as an edit to the original question. Commented Jul 15 at 4:53
  • Have you tried opening the android folder of your Flutter application in Android Studio and changing the Gradle JDK of the project? Because I see that you your compile options are for Java 11. Commented Jul 15 at 5:47
  • @tomerpacific I found that changing JAVA_HOME specifically in .bash_profile (not .bashrc) from 24 to 17, relogging in and then clearing the workspace cache caused the warning to go away. The question still remains though of why the warning mentioned JDK 21 when JAVA_HOME nor the Flutter config pointed to that - JAVA_HOME was set to JDK 24 and Flutter config was set to JDK 17 (and, for the record, making them the same did not change anything). [1/4] Commented Jul 15 at 22:18
  • I opened the android folder in android studio and then I saw that I was using AGP 8.7.3 (the instructions to install Flutter mentioned installing Android SDK Platform API 35, but when I installed Android Studio it came with API 36). Looking at the AGP 8.11 release notes I saw a table of minimum versions of tools for Android API levels. It showed that API 36 required a minimum AGP version of 8.9.1. I upgraded AGP using the tool (which also seemed to upgrade my gradle version from 8.12 to 8.13). [2/4] Commented Jul 15 at 22:18

1 Answer 1

2

i have the same issue and solve it buy install the java with devel since fedora in default install java headless (does not contains javac)

run this command in the terminal

sudo dnf install java-devel

if this not works use the java that comes with the android studio

in android/gradle.properties add the java

org.gradle.java.home=/{android_studio_location}/android-studio/jbr/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.