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

当前回答

在我的情况下,我从GitHub下载项目,Gradle文件丢失了。所以我只是创建了一个新的项目与成功建立。然后复制粘贴Gradle缺失的文件。重建项目对我来说是可行的。

其他回答

模块应用程序构建。gradle文件

apply plugin: 'com.android.application'

model{


    android {
        compileSdkVersion 23
        buildToolsVersion  "23.0.2"

        defaultConfig.with {
            applicationId "com.iamsafe"
            minSdkVersion 15
            targetSdkVersion 23





        }
     buildTypes {
            debug {
                minifyEnabled = false
                useProguard = true
                proguardFiles.add(file('proguard-rules.txt'))


            }
        }



    }

}



dependencies {
    compile 'com.android.support:support-v4:23.0.2'
    compile files('libs/asmack-android-8-0.8.10.jar')
    compile files('libs/commons-io-2.0.1.jar')
    compile files('libs/httpclient-osgi-4.2.1-sources.jar')
    compile files('libs/httpcore-4.3.2.jar')
    compile files('libs/httpmime-4.1.2.jar')
}


project 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:2.10'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

在我的情况下,我从GitHub下载项目,Gradle文件丢失了。所以我只是创建了一个新的项目与成功建立。然后复制粘贴Gradle缺失的文件。重建项目对我来说是可行的。

在项目级构建中。gradle文件,我已经替换了这一行

classpath 'com.android.tools.build:gradle:3.6.3'

用这个

classpath 'com.google.gms:google-services:4.3.3'

在添加这两行代码并同步之后,一切都变得正常了。 希望这能帮助到一些人。

这个问题发生在我不小心重命名行的时候

apply plugin: 'com.android.application'

在文件app/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工具类路径,并得到了错误。