I got an error
"Android Gradle plugin requires Java 11 to run. You are currenly 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.
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.