I am working on an Android project. My setup:
- Host development machine: Macbook
- Android studio Arctic Fox, 2020.3.1
- Android Gradle Plugin Version 7.0.0
- Gradle Version 7.0.2
- JDK 11 located under
Android Studio.app/Contents/jre/Contents/Home
When I try to import java.lang.ref.Cleaner in a java source file, I keep getting the "Cannot resolve symbol 'Cleaner'" compile error.
Here is what the relevant parts of my build.gradle file looks like:
After googling the issue for a while, the best explanation I could come up with is that Android is still on Java 8, but java.lang.ref.Cleaner is a Java 9+ feature. I tried selecting different versions of JDK in Android Studio, under the "Project Structure" menu, but it made no difference. Is it possible at all then to use Java 9 language features in an Android project?