为Firebase数据库添加“apply plugin:'com.google.gms.google-services'”时无法同步gradle

时间:2017-07-30 22:45:00

标签: android android-studio firebase firebase-realtime-database android-studio-2.3

我是Android Studio 2.3.3上的Android应用开发新手。我按照Firebase数据库指南连接到数据库。但是在执行同步时失败(参见下面的错误)。很多,因为我问同样的问题,但解决方案似乎过于特定于他们自己的gradle文件,所以我能够用它来修复我的应用程序。任何帮助将不胜感激: - )

Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.lenovo.hereandthere'

build.gradle(Project:HereAndThere)

// 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.3.3'
        classpath 'com.google.gms:google-services:3.1.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.lenovo.hereandthere"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

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

请注意: enter image description here

1 个答案:

答案 0 :(得分:0)

找不到与包名相匹配的客户' com.example.lenovo.hereandthere'

由于以下原因之一,可能会出现此问题:

  1. 没有谷歌服务.json文件存在
  2. 或google service .json文件存在但位于错误的位置。 check out this
  3. 或包名称与google service .json中提到的名称不同(人们通常不会这样做,但不幸的是,这个 是你的情况。)