相关疑难解决方法(0)

Android Gradle 插件需要 Java 11 才能运行。您当前使用的是 Java 1.8

我下载了最新的 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

我应该怎么做?

我的 Android Studio 版本 在此处输入图片说明

我的 Java 版本

    java 11.0.10 2021-01-19 LTS
    Java(TM) SE Runtime …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

201
推荐指数
27
解决办法
5万
查看次数

在集成 Jetpack Compose 时应用插件请求 [id: 'com.android.application'] 发生异常

我正在尝试使用 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)

android android-jetpack-compose

12
推荐指数
5
解决办法
6023
查看次数