这是我第一次尝试使用Android Studio。我安装了0.8.0并更新到0.8.2。只要一个项目被创建,我就会得到错误消息:

错误:(1,0)插件id 'com.android。未找到应用程序

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

当前回答

我也有类似的问题,我做了以下事情来解决它。 我参考了https://developer.android.com/studio/build 在应用插件行之前复制/粘贴下面这些行

repositories {
    google()
    jcenter()
}

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

}

其他回答

I was using IntelliJ IDEA 13.1.5 and faced with the same problem after I changed versions of Picasso and Retrofit in dependencies in build.gradle file. I tried use many solutions, but without result. Then I cloned my project from remote git (where I pushed it before changing versions of dependencies) and it worked! After that I just closed current project and imported old project from Gradle file to IntelliJ IDEA again and it worked too! So, I think it was strange bug in intersection of IDEA, Gradle and Android plugin. I hope this information can be useful for IDEA-users or anyone else.

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

最新的Gradle: 6.5

版本检查:

/ gradlew - v。

如何更新:

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

最新的Android Gradle插件:4.1.0

如果将以下代码片段添加到构建的顶部。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-gradle和https://dl.google.com/dl/android/maven2/index.html。

原来的答案

我有同样的错误,你需要确保你的Gradle版本与你的Android Gradle插件兼容。

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

我在一个小时的错误信息中挣扎后发现了问题:

我不小心重命名了根版本。Gradle到build中的文件名。gradle,所以Android Studio不再识别它了。

将其重命名为build。Gradle解决了这个问题!

[FOR FLUTTER]转到您的构建Gradle,然后检查是否有三条路径

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath 'com.google.gms:google-services:4.3.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

我以某种方式删除了android工具类路径,并得到了错误。

如果你在模块目录下运行android插件1.2.3的模块任务,就会出现这个问题。试试这个:

../gradlew -b ../build.gradle  -c ../settings.gradle  :module:xxx