这是我第一次尝试使用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文件,我已经替换了这一行

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

用这个

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

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

其他回答

还是有错误

 Could not find com.android.tools.build:gradle:3.0.0.

问题:jcenter()没有所需的库

解决方法:添加谷歌()作为repo

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {

        classpath "com.android.tools.build:gradle:3.0.0"
    }
}

打开你的成绩档案,你可以看到:

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


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

并将类路径更改为:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'

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

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

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

用这个

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

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

如果您错过添加顶级构建文件,就会发生这种情况。

只需添加构建。Gradle到顶级。

应该是这样的

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.xx.y'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

确保你的两个构建。Gradle和设置。Gradle文件在https://developer.android.com/studio/build/index.html的正确目录中

然后在Visual Studio中打开“as existing project”

Gradle对此非常挑剔。