为什么android studio显示错误"错误:(38,0)插件包含id' com.google.gms.google-services'找不到"

时间:2016-12-20 14:26:19

标签: java android build.gradle google-play-services google-admob

这是我在桌面上的gradle.build,它显示错误:

  

错误:(38,0)带有id' com.google.gms.google-services'的插件没找到。

有答案吗?

申请插件:' com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {
    applicationId "com.example.admin.youfame"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
   }
       buildTypes {
    release {
   minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
    }
}
}
  repositories {
   mavenCentral()
  }
  dependencies {
   compile fileTree(include: ['*.jar'], dir: 'libs')
  testCompile 'junit:junit:4.12'
   compile 'com.android.support:appcompat-v7:23.4.0'
   compile 'com.android.support:design:23.4.0'
   compile 'com.android.support:support-v4:23.4.0'
   compile 'com.android.support:cardview-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
  compile 'com.google.apis:google-api-services-youtube:v3- rev152-1.21.0'
    compile 'com.android.volley:volley:1.0.0'
     compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile 'com.google.firebase:firebase-ads:10.0.1'
   compile 'com.google.android.gms:play-services-ads:10.0.1'
   }

      apply plugin: 'com.google.gms.google-services'

2 个答案:

答案 0 :(得分:1)

添加您的顶级build.gradle Google Play服务插件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        //...
        classpath 'com.google.gms:google-services:3.0.0'

    }
}

然后您必须在模块中添加google-services.json文件

root
|--module
|----google-services.json

答案 1 :(得分:0)

您需要删除代码apply plugin:

com.google.gms.google-services

它有效。