javac warns that source value 8 is obsolete in an Android build
[options] source value 8 is obsolete and will be removed in a future releaseShort answer
The warning means the build asks a newer JDK to compile Java at language level 8. Raise sourceCompatibility and targetCompatibility to 17 (or set a toolchain), or, if you must stay on 8, pass -Xlint:-options to javac so only that category is hidden.
Fix it fast
1Find out which cause you have
Find where the Java level is set. It is either in compileOptions of the Android module or inherited from the toolchain.
grep -rnE "sourceCompatibility|targetCompatibility|toolchain|VERSION_1_8" app/build.gradle* build.gradle*2Match what you see, then jump to its fix
- 1
VERSION_1_8 appears in compileOptionscompileOptions still asks for Java 8Fix - 2
A java module (not the Android app) prints the warningA toolchain or release flag in a plain Java module sets 8Fix - 3
A library or minSdk forces level 8 and the warning is the only problemYou must stay on Java 8 and only want the warning goneFix
- 1
What does the error look like?
[options] source value 8 is obsolete and will be removed in a future release
Cause 1 of 3
compileOptions still asks for Java 8
1Check
sourceCompatibility sets which Java language features are available; targetCompatibility sets the bytecode version. Both default to the toolchain version when you do not set them.
grep -n "VERSION_1_8" app/build.gradle app/build.gradle.kts 2>/dev/null2Fix
Set both to the same newer level, and keep targetCompatibility at or above sourceCompatibility. Check that your minSdk supports the features you start using.
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}3Verify
Rebuild and look for the warning in the compile output.
./gradlew :app:compileDebugJavaWithJavacConfirmed by developer.android.com
Cause 2 of 3
A toolchain or release flag in a plain Java module sets 8
1Check
Gradle recommends a toolchain, plus options.release when you cross-compile to an older level, and says sourceCompatibility and targetCompatibility should be avoided where toolchains work.
grep -rn "release" --include=build.gradle* .2Fix
Pin the toolchain and the release level in the module build file.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release = 17
}3Verify
Run the compile task again.
./gradlew compileJavaConfirmed by docs.gradle.org
Cause 3 of 3
You must stay on Java 8 and only want the warning gone
1Check
The javac options lint category covers warnings about command-line options. A key preceded by a hyphen disables that warning.
./gradlew :app:compileDebugJavaWithJavac --info | grep -i options2Fix
Pass -Xlint:-options to javac. It hides this category only; other warnings stay.
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:-options")
}3Verify
Rebuild; the [options] lines should be gone.
./gradlew :app:compileDebugJavaWithJavacConfirmed by docs.oracle.com
How do I stop it coming back?
- Set the Java level in one place and keep the toolchain version equal to it.
- Do not mix --release with -source or -target; javac rejects the combination.
- Plan the move off level 8 instead of hiding the warning for good.
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
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix