错误:(1, 0) 未找到 ID 为“com.android.application”的插件

2024-02-11

这是我第一次尝试 Android Studio。我安装了0.8.0并更新到0.8.2。创建项目后,我收到错误消息:

错误:(1, 0) 未找到 ID 为“com.android.application”的插件

C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.example.bob.helloagain6"
        minSdkVersion 15
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

和 C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'

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

allprojects {
    repositories {
        jcenter()
    }
}

更新答案(2020 年 12 月 2 日)

最新的摇篮: 6.5 https://services.gradle.org/distributions/

版本检查:

  • ./gradlew -v

如何更新:

  • 设置网址:./gradlew wrapper --gradle-version=6.5 --distribution-type=all
  • Update: ./gradlew wrapper

最新的 Android Gradle 插件: 4.1.0

如果添加以下代码片段到顶部你的build.gradle文件。 Gradle 将更新构建工具。

buildscript {
    repositories {
        google() // For Gradle 4.0+
        maven { url 'https://maven.google.com' } // For Gradle < 4.0
    }

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

在这里阅读更多内容:https://developer.android.com/studio/build/index.html https://developer.android.com/studio/build/index.html以及关于版本兼容性的信息:https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle and https://dl.google.com/dl/android/maven2/index.html https://dl.google.com/dl/android/maven2/index.html.

原答案

我也遇到了同样的错误,你需要确保你的Gradle 版本与您的 Android Gradle 插件兼容。

Gradle 的最新版本是2.0但你需要使用1.12为了使用 Android Gradle 插件。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误:(1, 0) 未找到 ID 为“com.android.application”的插件 的相关文章

随机推荐