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

标签 android flutter gradle android-gradle-plugin

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

Error:(1, 0) Plugin with id 'com.android.application' not found

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 日)

最新 Gradle: 6.5

版本检查:

  • ./gradlew -v

如何更新:

  • 设置 URL:./gradlewwrapper --gradle-version=6.5 --distribution-type=all
  • 更新:./gradlew 包装器

最新 Android Gradle 插件:4.1.0

如果您将以下代码 fragment 添加到 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/releases/gradle-plugin.html#updating-gradlehttps://dl.google.com/dl/android/maven2/index.html .

原始答案

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

Gradle 的最新版本是2.0,但您需要使用1.12才能使用 Android Gradle 插件。

关于android - 错误 :(1, 0) 未找到 ID 为 'com.android.application' 的插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61011833/

相关文章:

gradle - 找到 Gradle 版本 Gradle 7.4。 FG3 不支持 Gradle 6.0.0 及更新版本,但 FG4 支持 6.8.1 及更新版本

java - 为什么不能设置随机颜色?

java - 即使添加 jar 后也出现 ClassNotFoundException

flutter - 如何在不使用 Playstore 或 App Store 的情况下升级我的 Flutter 应用程序?

arrays - 无法接收要建模的数组

java - 如何使用shadowJar gradle插件而不是maven发布将fat JAR发布到JitPack

android-studio - Kotlin + Gradle Unresolved reference

android - 以非常快速的方式在android中逐像素绘制图像

java - 如何在我当前的 android 系统中获取我的 wifi 热点 ssid

flutter - 当前未查看时跳过重新构建重载小部件