skip to Main Content

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

4

Answers


  1. Chosen as BEST ANSWER

    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.


  2. Change your Gradle settings to this :
    Not the Embedded JDK

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

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search