Using Firebase Cloud Service getting Error:AppProcessDebugGoogle Service- No matching client found for package name

Using Firebase Cloud Service getting Error:AppProcessDebugGoogle Service- No matching client found for package name

我正在使用 Firebase 云消息传递进行推送通知。

我按照官方网站的所有说明成功添加了所有要求。但是我收到一个错误并且无法找到任何解决方案。

我的错误是:

  Error:Execution failed for task ':app:processInmemoryDebugGoogleServices'.
  > No matching client found for package name 'in.voiceme.app.voiceme.inmemory' 

我添加的地方 google-service.json 看。

我的项目结构看起来像

我已经添加了依赖:

   compile 'com.google.firebase:firebase-messaging:9.4.0'
   apply plugin: 'com.google.gms.google-services'

添加类路径:

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

        *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
    }
 }

我的应用基于 Build.Gradle

      apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "in.voiceme.app.voiceme"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        inmemory {
            applicationId "in.voiceme.app.voiceme.inmemory"
        }

        live {
            applicationId "in.voiceme.app.voiceme"
        }
     }
   }

    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:24.2.0'
        compile 'com.android.support:design:24.2.0'
        compile 'com.google.firebase:firebase-messaging:9.0.0'
    }
apply plugin: 'com.google.gms.google-services'

谁能给我解决这个错误的方法?

因为 "inmemory" build flavor 使用与其他版本不同的包名称 (applicationId),您需要修改 google-services.json 文件或者提供它的多个副本。 documentation for the Google Services Gradle Plugin 描述了不同构建类型和风格的文件夹结构。

如果您的应用构建类型和风格不需要不同的项目设置,则可以使用单个文件并向文件中的 client 数组添加一个条目。添加的条目将指定包名称 in.voiceme.app.voiceme.inmemory。有关更多详细信息,请参阅链接文档,特别是有关 处理 JSON 文件.

的部分

一个相关的问题也会有帮助。

感谢 @qbix

我解决了这个问题
 for productFlavors 

    inmemory {
        applicationId "in.voiceme.app.voiceme.inmemory"
    }

 Need to create different `google-service.json` using firebase console 
 and copy this json file into `inmemory` package.

我发现问题是不同的 pakageName not found by google-service.json,当我们从 Firebase 控制台创建它时 json 文件存储 pakageName。

provide new `google-service.json` to inmemory package is solution for that issue. thanks again @qbix