android + sourceCompatibility JavaVersion.VERSION_11: error: package android.os does not exist

Viewed 5394

I'm trying to play with Java11 APIs in android application and failed to make it compile.

Steps to fail:

  1. Using current version of Android Studio 4.1.2 - generated dummy project "Basic Activity"
  2. Build & Launch - everything OK so far
  3. Open app/build.gradle and set sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11
  4. In Project Structure > SDK Location > JDK Location - select path to JDK 11
  5. Build ... and it fails with following error
FirstFragment.java:3: error: package android.os does not exist

So the question is - what am I doing wrong? What is missing to build the project with sourceCompatibility JavaVersion.VERSION_11?

1 Answers
Related