title: Android with sourceCompatibility = JavaVersion.VERSION_11 gives error error: "package android.app does not exist"
body: <p>When using the JDK 11 target, then I get this error:</p>
  <blockquote>
  <p>error: package android.app does not exist</p>
  </blockquote>
  <p><strong>I saw a solution</strong> <a href="https://stackoverflow.com/questions/66551892/android-sourcecompatibility-javaversion-version-11-error-package-android-os">to upgrade to the 'Canary' AS version</a>. I prefer to use the beta or stable Android Studio version. I have updated it regularly. Not planning a major change for just an upgrade.</p>
  <p>So, this works well: even with an Android Studio &quot;Project settings&quot; and &quot;JDK&quot; with &quot;JDK 11&quot;.</p>
  <p>When the build.gradle has these compile options, everything works fine.</p>
  <pre><code>compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
  }
  </code></pre>
  <p>This gives the mentioned errors:</p>
  <pre><code>compileOptions {
      sourceCompatibility = JavaVersion.VERSION_11
      targetCompatibility = JavaVersion.VERSION_11
  }
  </code></pre>
  <p>My build.grade project file is:</p>
  <pre><code>buildscript {
      repositories {
          mavenCentral()
          jcenter()
          google()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:4.2.1'
          classpath 'org.ajoberstar:grgit:3.3'
      }
  }
  
  allprojects {
      repositories {
          maven { url &quot;https://jitpack.io&quot; }
          google()
      }
  }
  </code></pre>
  <p>Parts of my build.grade module file is:</p>
  <pre><code>apply plugin: 'com.android.application'
  repositories {
      mavenCentral()
      maven { url &quot;https://jitpack.io&quot; }
      google()
  }
  </code></pre>
  <p>How can I build normally using the (Oracle) JDK 11 compiler?</p>