0

Android Studio is not recognizing features from Java 11+ even though the JDK is version 18. I discovered this when I needed the repeat() method (introduced in Java 11) and AS would throw Cannot resolve method, but later tried more features from Java 11 onwards and they weren't recognized.

I set my JDK version and location as follows in the settings (from what I searched, this is the only setting related to JDK in Android Studio). Android Studio JDK Settings

I've reinstalled Android Studio twice, invalidated my caches, redownloaded the JDK twice. Note: IntelliJ IDEA is able to recognize features using the same exact JDK as Android Studio.

Please help if you've ever had this issue because I'm slowly losing my mind over this.

  • 1
    It appears that Android does not use the Java on your desktop but runs its own version of Java, which does not support the same desktop features. https://stackoverflow.com/questions/54129834/which-android-versions-run-which-java-versions – markspace Jun 21 '22 at 20:20
  • 1
    You currently can't use Java11 API in Android. Java 8 API are the latest supported yet: https://developer.android.com/studio/write/java8-support. Better if you move to Kotlin if you want to work with modern language features – MatPag Jun 21 '22 at 22:00
  • 1
    Thank you both for answering, I understand what's going on now. –  Jun 21 '22 at 22:06

0 Answers0