【发布时间】:2017-03-18 21:16:25
【问题描述】:
我正在尝试安装推送通知并按照 firebase 上的说明进行操作,但在我的 gradle 文件中添加这些行并尝试同步后,我收到以下错误。
错误:任务 ':app:processDebugGoogleServices' 执行失败。 找不到与包名称“com.project.myproject”匹配的客户端
我下载了 google-services.json 文件并将其放在我的项目下的应用程序文件夹中。
这是我的成绩文件
应用程序
// 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.2.2'
classpath 'com.google.gms:google-services:3.0.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
}
模块
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.project.myproject"
minSdkVersion 15
targetSdkVersion 24
versionCode 39
versionName "1.0.0.39"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-messaging:9.8.0'
}
apply plugin: 'com.google.gms.google-services'
【问题讨论】:
-
你能发布你的树文件层次结构吗?你检查你的 google-services.json package_name 是否和你的 applicationId 一样?
-
是的包名是一样的。我花了一个小时寻找这个问题,发现了类似的问题,但没有一个答案对我有用。但问题。 google-services.json 是否只应该在 APP 文件夹中?或者其他地方也......用于调试等?
-
文件树层次结构?在项目视图下?我的 app 文件夹中只有一个 google 服务文件
-
如果您不需要为每种口味使用不同的文件,您可以只使用一个。如果您需要它,您应该为每个项目创建一个不同的项目(在 firebase 控制台中),然后使用相应的 .json 来获得正确的风格:stackoverflow.com/a/39305974/1423773
标签: android android-studio firebase push-notification google-play-services