首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >原因: org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件[id 'com.android.application']

原因: org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件[id 'com.android.application']
EN

Stack Overflow用户
提问于 2019-12-13 16:50:23
回答 2查看 14.3K关注 0票数 2

Android Studio 3.6

代码语言:javascript
运行
复制
build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.AA_VERSION = '4.4.0'
    ext.kotlin_version = '1.2.21'
    ext.BUTTER_KNIFE_VERSION = '8.8.1'
    ext.GLIDE_VERSION = '4.2.0'

    repositories {
        google()
        jcenter()
    }
    dependencies {
       classpath 'com.android.tools.build:gradle:3.6.0-beta05'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

在app/build.gradle中

代码语言:javascript
运行
复制
buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }
    }

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'kotlin-android'

    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(rootProject.file("app/keystore.properties")))

    android {
        dataBinding {
            enabled = true
        }
        // Configure only for each module that uses Java 8
        // language features (either in its source code or
        // through dependencies). E.g. lambda expressions.
        compileOptions {
            targetCompatibility JavaVersion.VERSION_1_8
            sourceCompatibility JavaVersion.VERSION_1_8
        }
        compileSdkVersion 29
        defaultConfig {
        applicationId "com.myproject"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 1
        versionName "0.0.1"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    def anko_version = '0.10.4'

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:design:26.1.0'
        implementation "com.github.bumptech.glide:glide:$GLIDE_VERSION"
        implementation 'org.greenrobot:eventbus:3.0.0'
        implementation "com.jakewharton:butterknife:$BUTTER_KNIFE_VERSION"
        implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
        implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
        implementation 'com.squareup.retrofit2:retrofit:2.3.0'
        implementation "org.androidannotations:androidannotations-api:$AA_VERSION"
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
        implementation "org.jetbrains.anko:anko:$anko_version"

        annotationProcessor "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION"
        annotationProcessor "org.androidannotations:androidannotations:$AA_VERSION"

        implementation project(':common')

        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
        androidTestImplementation 'com.squareup.okhttp:mockwebserver:2.7.0'
    }

但从Android Studio启动时出现错误:

代码语言:javascript
运行
复制
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']

但是当像这样从控制台启动时:

代码语言:javascript
运行
复制
gradlew build

我得到另一个错误:

代码语言:javascript
运行
复制
Build file 'D:\dev\mobile\TAgent\app\build.gradle' line: 7

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.internal.version-check']
   > Cannot parse project property android.enableD8='true ' of type 'class java.lang.String' as boolean. Expected 'true' or 'false'.

在这一行中:

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'
EN

回答 2

Stack Overflow用户

发布于 2020-11-09 01:30:30

org.gradle.api.internal.plugins.PluginApplicationException:你通常会得到这样的信息,因为你尝试使用的插件版本和所需的Gradle版本不匹配。

看看下面的链接,找到一个指导你的列表,它肯定解决了我的问题

https://developer.android.com/studio/releases/gradle-plugin

获得Gradle版本后,导航到gradle-wrapper.properties并编辑distributionUrl。干杯

票数 0
EN

Stack Overflow用户

发布于 2021-03-01 14:46:19

Gradle是一个构建工具,android gradle插件是一个插件。它们的版本有一些关系:

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

当插件的版本太新而gradle的版本太旧时,这个问题就会出现。

一种解决方案是:打开根build.gradle文件,更改android gradle插件的版本,如下所示:

代码语言:javascript
运行
复制
buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        ...
    }
}

如果这不起作用,请将该版本设置得更小,直到某些版本起作用为止。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59319015

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档