这是我第一次尝试使用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()
    }
}

当前回答

这也可能发生时,您有两个设置。Gradle和settings.gradle.kts文件在项目根目录中(可能包含相同的模块)。您应该只有其中一个文件。

其他回答

[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工具类路径,并得到了错误。

Root-gradle文件:

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

allprojects {
    repositories {
        jcenter()
    }
}

Gradle-wrapper。属性文件:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip

这也可能发生时,您有两个设置。Gradle和settings.gradle.kts文件在项目根目录中(可能包含相同的模块)。您应该只有其中一个文件。

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.

我写这篇文章不是为了解决很多人的问题,而是为了解决一些人的问题,他们可能犯了一个简单的错误,比如从SVN导入项目时指定了错误的url。它是为那些家伙准备的:)

当我从SVN导入项目时发生了这种情况->自动提示Studio打开项目->它要求Gradle位置-> D:\Software\Android\ Gradle -2.5 ->然后出现错误。

在不同的SVN分支中的同一个项目可以很好地使用Gradle插件和我在Studio中配置的Gradle。我试着改变Android Gradle插件和Gradle,让它在错误的分支上工作,但没有任何成功。

最后,我发现我犯了以下错误: 我尝试单独导入一个特定的应用程序,而不是将应用程序与依赖的库项目一起导入。 我最初用于导入的url末尾有应用程序项目的名称。一旦我删除了它,并指定了父目录,其中包含应用程序项目和它的依赖项目,一切都很顺利:)