title: Android Studio Error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"
body: <p>I downloaded the newest Android Studio, and I wanted to run the Android Jetpack Compose Project, but when I ran it, I got the error:</p>
  <pre class="lang-none prettyprint-override"><code>&gt; Failed to apply plugin 'com.android.internal.application'.
  &gt; 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 `org.gradle.java.home` in `gradle.properties`.
  </code></pre>
  <p>I already downloaded Java 11 and added Java 11 in <em>gradle.properties</em>.</p>
  <pre class="lang-none prettyprint-override"><code>org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
  </code></pre>
  <p>The JAVA_HOME shows Java 11, but when I run, it doesn't work -
  <code>/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home</code></p>
  <p>How should I do?</p>
  <p>My Android Studio version</p>
  <p><a href="https://i.stack.imgur.com/VLFU2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VLFU2.png" alt="Enter image description here" /></a></p>
  <p>My Java version</p>
  <pre class="lang-none prettyprint-override"><code>java 11.0.10 2021-01-19 LTS
  Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
  Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
  </code></pre>
  <p>My <em>gradle-wrapper.properties</em></p>
  <pre class="lang-none prettyprint-override"><code>distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
  </code></pre>
  <p><em>build.gradle</em> classpath</p>
  <pre class="lang-none prettyprint-override"><code>classpath &quot;com.android.tools.build:gradle:7.0.0-alpha13&quot;
  classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31&quot;
  </code></pre>
  <p>File <em>build.gradle</em></p>
  <pre class="lang-none prettyprint-override"><code>plugins {
      id 'com.android.application'
      id 'kotlin-android'
  }
  
  android {
      compileSdk 30
  
      defaultConfig {
          applicationId &quot;com.example.testandroid3&quot;
          minSdk 21
          targetSdk 30
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          vectorDrawables {
              useSupportLibrary true
          }
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_11
          targetCompatibility JavaVersion.VERSION_11
      }
      kotlinOptions {
          jvmTarget = &quot;11&quot;
          useIR = true
      }
      buildFeatures {
          compose true
      }
      composeOptions {
          kotlinCompilerExtensionVersion compose_version
          kotlinCompilerVersion '1.4.31'
      }
  }
  
  java {
      toolchain {
          languageVersion.set(JavaLanguageVersion.of(11))
      }
  }
  
  dependencies {
  
      implementation 'androidx.core:core-ktx:1.3.2'
      implementation 'androidx.appcompat:appcompat:1.2.0'
      implementation 'com.google.android.material:material:1.2.1'
      implementation &quot;androidx.compose.ui:ui:$compose_version&quot;
      implementation &quot;androidx.compose.material:material:$compose_version&quot;
      implementation &quot;androidx.compose.ui:ui-tooling:$compose_version&quot;
      implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
      implementation 'androidx.activity:activity-compose:1.3.0-alpha02'
      testImplementation 'junit:junit:4.13.2'
      androidTestImplementation 'androidx.test.ext:junit:1.1.2'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
      androidTestImplementation &quot;androidx.compose.ui:ui-test-junit4:$compose_version&quot;
  }
  </code></pre>