'After fixing "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8" Android studio emulator still doesn't work

I got an error

"Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"

I change it in IDE settings and JAVA_HOME environment variable. Errors in the terminal and build disappeared but emulator still doesn't work.

My versions My versions

Error in the emulator

Error in the emulator

The root cause of the problem

The root cause of the problem

If anyone can, please help



Solution 1:[1]

The reason was obvious. I changed emulator, I don't understand why, but my ex emulator stopped working. I reinstall it many times (Nexus 5x), and changed api but it did not helped. Accidentally I installed Nexus 5 and all started work corectly.

Solution 2:[2]

I faced this problem in react native "react-native": "0.68.1" in mac-m1
& Java version is 1.8, instead of upgrading to java-11
i resolved error by running a diagnostic check using npx @react-native-community/cli doctor
What is purpose of latest doctor command in React Native

Solution 3:[3]

Change your Gradle settings to this : Not the Embedded JDK

And keep the Gradle in App directory in v1.8 : App Gradle - Compile Option

Solution 4:[4]

Regards this type of issue we can create a demo to check the configuration.

For an instance, I created a demo with Empty Activity and using Kotlin.

The configuration looks like this:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.teststackoverflow"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

// Please check this
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

// Please check this
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

And we also need to check the configuration on the menu of Project Structure I always used the Embedded JDK which is in location of Android Sutido Of course? you can specify other JDK you want to use.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vlad Kuzmuk
Solution 2 abhish
Solution 3 Shogun Nassar
Solution 4 shrimpcolo