我下载了最新的 Android Studio,我想运行 Android Jetpack Compose 项目,但是当我运行时,出现错误:
> Failed to apply plugin 'com.android.internal.application'.
> 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`.
Run Code Online (Sandbox Code Playgroud)
我已经下载了 Java 11,并在 gradle.properties 中添加了 java 11。
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)
JAVA_HOME 显示 Java 11,但我运行,它不起作用,
/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
我应该怎么做?
我的 Java 版本
java 11.0.10 2021-01-19 LTS
Java(TM) SE Runtime …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Canary 8实现JetPack Compose,但每次尝试同步 gradle 时都会收到此错误
应用插件请求时发生异常 [id: 'com.android.application']
我的 app\build.gradle 文件在下面
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.myapplication"
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '11'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.30' …Run Code Online (Sandbox Code Playgroud)