简体   繁体   English

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

[英]Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']

Android Studio 3.6安卓工作室 3.6

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
    }
}

in app/build.gradle在 app/build.gradle 中

  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'
    }

But I get error when start from Android Studio:但是从 Android Studio 启动时出现错误:

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']

But when start from console like this:但是当像这样从控制台启动时:

gradlew build

I get another error:我收到另一个错误:

 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'.

In this line:在这一行:

apply plugin: 'com.android.application'

org.gradle.api.internal.plugins.PluginApplicationException: You usually get this because the plugin version you are trying to use and the required Gradle version do not match. org.gradle.api.internal.plugins.PluginApplicationException:您通常会收到此异常,因为您尝试使用的插件版本与所需的 Gradle 版本不匹配。

Check out the link below to find a list that will guide you, it surely solved my problem https://developer.android.com/studio/releases/gradle-plugin查看下面的链接以找到可以指导您的列表,它确实解决了我的问题https://developer.android.com/studio/releases/gradle-plugin

Once you have the Gradle version, navigate to the gradle-wrapper.properties and edit the distributionUrl.一旦你有了 Gradle 版本,导航到 gradle-wrapper.properties 并编辑 distributionUrl。 Cheers干杯

Gradle is a building tool, and android gradle plugin is a plugin. Gradle 是一个构建工具,android gradle plugin 是一个插件。 Their versions have some relationships:它们的版本有一些关系:

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

That problem will raise when plugin's version is too new and gradle's version is too old.当插件的版本太新而 gradle 的版本太旧时,这个问题就会出现。

One solution: Open the root build.gradle file, and change the android gradle plugin's version like this:一种解决方案:打开根 build.gradle 文件,并像这样更改 android gradle 插件的版本:

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        ...
    }
}

If that not work, make that version more smaller until some version works.如果这不起作用,请使该版本更小,直到某个版本有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件[id 'kotlin-android'] - Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'kotlin-android'] 原因:org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件 [id 'dexguard'] - Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'dexguard'] Android Studio - 无法应用插件 [id 'com.android.application'] - Android Studio - Failed to apply plugin [id 'com.android.application'] 无法应用插件[id'com.android.application']需要Gradle版本2.10。 当前版本是2.4 - Failed to apply plugin [id 'com.android.application'] Gradle version 2.10 is required. Current version is 2.4 Android gradle 应用插件:'com.android.application' - Android gradle apply plugin: 'com.android.application' 如何修复Gradle同步失败“找不到ID为'com.android.application'的插件”? - How Can I fix Gradle sync failed “Plugin with id 'com.android.application' not found”? gradle 找不到 ID 为“com.android.application”的构建错误插件 - gradle build error Plugin with id 'com.android.application' not found 无法应用插件[id'com.android.application']>您的项目包含2个或多个具有相同标识的模块 - Failed to apply plugin [id 'com.android.application'] > Your project contains 2 or more modules with the same identification 找不到ID为“ com.android.application”的插件 - Plugin with id 'com.android.application' not found 如何使用新的插件 DSL 应用 com.android.application 插件? - How to apply the com.android.application plugin using the new plugins DSL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM