I’m currently working on an Android project in Android Studio and I’m getting the following warnings:
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
I understand that these warnings are related to the Java version being used, but I’m not sure how to update the source and target values to fix this issue.
Could someone please guide me on how to update the Java source and target compatibility in my project, or if there’s another way to suppress these warnings?
Thank you
2
Answers
Read The Fine Manual.
In
build.gradle
put:If using
build.gradle.kts
, put:Doing either supplies defaults for
sourceCompatibility
andtargetCompatibility
.I recently faced the exact issue while working on my Flutter project, and after two days of troubleshooting, I found a solution that worked for me. The problem stems from an incompatibility between the Java Development Kit (JDK) version and the Gradle configuration. Here’s how I resolved it:
Flutter projects currently work best with JDK 17 for the latest Gradle and Android plugin versions. You can download JDK 17 from the official OpenJDK website. JDK 17 – Setup file
Ensure that the compileOptions and kotlinOptions target JDK 17:
Set the distributionUrl to a compatible Gradle version, such as 8.10.2:
Ensure the plugin versions are compatible with JDK 17 and Gradle 8.3.2:
I struggled with these warnings for two days before discovering the solution. It wasn’t immediately clear that the issue lay in the mismatch between Java, Gradle, and plugin versions. By systematically adjusting configurations and testing, I was able to eliminate the warnings and build my project successfully.
If you’re facing similar issues, I hope this solution saves you time and frustration! Let me know if you encounter any challenges implementing these changes.