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



我是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 (项目: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 (模块:应用程序(

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'

注意: 在此处输入图像描述

找不到软件包名称"com.example.lenovo.hereandthere"的匹配客户端

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

  1. 不存在谷歌服务 .json 文件
  2. 或谷歌服务.json文件存在,但放置在错误的位置。 看看这个
  3. 或者软件包名称与谷歌服务.json中提到的名称不同(人们通常不会这样做,但不幸的是,这 是你的情况。

相关内容

最新更新