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
Error in the emulator
The root cause of the problem
If anyone can, please help
CodePudding user response:
Change your Gradle settings to this :
And keep the Gradle in App directory in v1.8 :
CodePudding user response:
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.
CodePudding user response:
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.