在集成Jetpack合成时应用插件请求[id:'com.android.Application']时出现异常

An exception occurred applying plugin request [id: #39;com.android.application#39;] while integration Jetpack Compose(在集成Jetpack合成时应用插件请求[id:#39;com.android.Application#39;]时出现异常)

本文介绍了在集成Jetpack合成时应用插件请求[id:'com.android.Application']时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Canary 8实现Jetpack Compose,但每次尝试同步Gradle时都收到此错误

应用插件请求时出现异常[id:‘com.android.application’]

我的appuild.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'
    }
}
dependencies {
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha06'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha02'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

我的build.gradle文件在下面

buildscript {
    ext {
        compose_version = '1.0.0-beta01'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0-alpha08'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30"
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的Gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-6.8.2-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

推荐答案

Android Gradle插件7需要JAVA 11。

转到File&>Project Structure并将JDK位置更改为Embedded JDK

这篇关于在集成Jetpack合成时应用插件请求[id:'com.android.Application']时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在集成Jetpack合成时应用插件请求[id:'com.android.Application']时出现异常

基础教程推荐