Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter Android build prints 'source value 7 is obsolete and will be removed'

Errorwarning: [options] source value 7 is obsolete and will be removed in a future release

Short answer

The warning comes from javac, not Flutter. Some Gradle module compiles Java with an old language level, and the JDK running the build is newer. If the module is yours, set sourceCompatibility and targetCompatibility to 17. If it is a plugin you do not own, hide the options lint for that task.

  • Applies to Flutter 3.3x stable, Android Gradle Plugin 8.x, JDK 17, Gradle 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Run a verbose Gradle build so the warning appears with the task that printed it. The task name, such as :some_plugin:compileDebugJavaWithJavac, shows which module owns the old setting.

    cd android
    ./gradlew app:assembleDebug --warning-mode all
  2. 2Match what you see, then jump to its fix

    1. 1The task named in the warning is :app:compileDebugJavaWithJavacYour own module sets an old Java levelFix
    2. 2The task named in the warning belongs to a plugin, for example :some_plugin:compileDebugJavaWithJavacA plugin or library you do not own compiles with the old levelFix

What does the error look like?

  • warning: [options] source value 7 is obsolete and will be removed in a future release
  • warning: [options] target value 7 is obsolete and will be removed in a future release
  • warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.

Cause 1 of 2

Your own module sets an old Java level

1Check

Open android/app/build.gradle and look at compileOptions. sourceCompatibility defaults to the Java toolchain, or to a version the Android Gradle Plugin picks, when you leave it out.

grep -n -A4 compileOptions android/app/build.gradle*

2Fix

Set both values explicitly. Android's docs recommend the same value for both, and targetCompatibility must be equal to or higher than sourceCompatibility.

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
}

3Verify

Rebuild and check that the warning for :app is gone.

cd android
./gradlew app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

A plugin or library you do not own compiles with the old level

1Check

First try updating the plugin to a newer release that raised its level.

flutter pub outdated

2Fix

Update the plugin. If no update exists, the warning is harmless and can be hidden for all Java tasks with the options lint key, which javac documents under -Xlint. Add this to android/build.gradle.

subprojects {
    tasks.withType(JavaCompile).configureEach {
        options.compilerArgs.add("-Xlint:-options")
    }
}

3Verify

Rebuild; the [options] lines no longer print.

cd android
./gradlew app:assembleDebug

Confirmed by docs.oracle.com

Did this fix it?

How do I stop it coming back?

  • Set sourceCompatibility and targetCompatibility in every module you own.
  • Keep plugins current with flutter pub outdated.
  • Read the task name in a warning before editing any build file.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Flutter Android: Failed to load FirebaseOptions from resource

Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.

On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json.

4 causes, each with a fix

Mobile apps

Flutter's Android build stops: JAVA_HOME is not set

ERROR: JAVA_HOME is set to an invalid directory

The Gradle wrapper script needs a Java runtime and looks in two places: the JAVA_HOME variable, then a java command on PATH.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.