title: Error: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. -& Failed to apply plugin 'com.android.internal.application'
body: <p>I have tried all the possible solutions for this error. Require guidance here:</p>
  <p>I am using Windows Laptop : Android Studio 2020.3.1.22</p>
  <p>Below is the build.graddle file:</p>
  <pre><code>plugins {
      id 'com.android.application'
      id 'kotlin-android'
  }
  
  android {
      compileSdk 31
  
      defaultConfig {
          applicationId &quot;com.example.myapplication3&quot;
          minSdk 21
          targetSdk 31
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          multiDexEnabled = true
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          // Flag to enable support for the new language APIs
          coreLibraryDesugaringEnabled = true
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
      kotlinOptions {
          jvmTarget = '1.8'
      }
  }
  
  dependencies {
  
      implementation 'androidx.core:core-ktx:1.6.0'
      implementation 'androidx.appcompat:appcompat:1.3.1'
      implementation 'com.google.android.material:material:1.4.0'
      implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
      testImplementation 'junit:junit:4.+'
      androidTestImplementation 'androidx.test.ext:junit:1.1.3'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
      coreLibraryDesugaring(&quot;com.android.tools:desugar_jdk_libs:1.1.5&quot;)
  }
  </code></pre>
  <p>also my graddle wrapper properties:</p>
  <pre><code>distributionBase=GRADLE_USER_HOME
  distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
  distributionPath=wrapper/dists
  zipStorePath=wrapper/dists
  zipStoreBase=GRADLE_USER_HOME
  </code></pre>
  <p>my output of ./gradlew --version</p>
  <pre><code>Gradle 7.0.2
  ------------------------------------------------------------
  
  Build time:   2021-05-14 12:02:31 UTC
  Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e
  
  Kotlin:       1.4.31
  Groovy:       3.0.7
  Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
  JVM:          1.8.0_275 (Azul Systems, Inc. 25.275-b01)
  </code></pre>
  <p>Android Sdk version: C:\Users\User name\AppData\Local\Android\Sdk
  Gradle JDK: 11 version 11.0.12 C:\Program Files\Java\jdk-11.0.12</p>
  <p>Java Version:</p>
  <pre><code>C:\Users\Vainav Shah\StudioProjects\MyApplication3&gt;java --version
  java 16.0.2 2021-07-20
  Java(TM) SE Runtime Environment (build 16.0.2+7-67)
  Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
  </code></pre>
  <p>Please guide to resolve this error:
  An exception occurred applying plugin request [id: 'com.android.application']</p>
  <blockquote>
  <p>Failed to apply plugin 'com.android.internal.application'.
  Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
  You can try some of the following options:
  - changing the IDE settings.
  - changing the JAVA_HOME environment variable.
  - changing <code>org.gradle.java.home</code> in <code>gradle.properties</code>.</p>
  </blockquote>