繁体   English   中英

找不到具有不同 buildvariant 的 package 名称“....”的匹配客户端

[英]No matching client found for package name "...." with different buildvariant

我想实施推送通知。 我添加到项目级别:

dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.google.gms:google-services:3.0.0'
}

和应用程序级别:(在文件底部)

   ....
   compile 'com.squareup.okhttp3:okhttp:3.3.0'
}
apply plugin: 'com.google.gms.google-services'

然后我将 google-services.json 文件添加到应用程序级别的项目中

但是,当我同步 gradle 时,它启动错误:

No matching client found for package name "...." 

在 gradle 中,我有 2 个不同的构建变体,看起来像:

在此处输入图像描述

显现:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="es.xxx.awsomeapp">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:name=".realm.XXXXXX"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher_chv"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity

最后是 gradle:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
    maven { url "https://jitpack.io" }
    maven { url 'http://dl.bintray.com/amulyakhare/maven' }
    mavenCentral()
}
android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    productFlavors {
        vanilla {
            applicationId "es.xxx.awsomeApp"
            resValue 'string', 'app_name', "Awsome"
        }
        chv {
            applicationId "es.xxx.awsomeApp.chv"
            resValue 'string', 'app_name', "Awsome CHV"
            signingConfig signingConfigs.chv_release
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //Auxiliar libraries
    compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0-beta2'
    //Auxiliar libraries
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'org.igniterealtime.smack:smack-android-extensions:4.2.0-beta2'
    compile 'org.igniterealtime.smack:smack-tcp:4.2.0-beta2'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta2'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.orhanobut:logger:1.15'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'com.github.Slyce-Inc:SlyceMessaging:1.1.2'
    compile 'io.realm:android-adapters:1.4.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.rengwuxian.materialedittext:library:1.8.3'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.squareup.okhttp3:okhttp:3.3.0'
    compile 'com.google.firebase:firebase-messaging:9.8.0'
    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    testCompile 'com.android.support:appcompat-v7:24.2.1'
    testCompile 'org.igniterealtime.smack:smack-tcp:4.2.0-beta2'
    testCompile 'com.android.support.constraint:constraint-layout:1.0.0-beta2'
    testCompile 'com.android.support:design:24.2.1'
    testCompile 'com.orhanobut:logger:1.15'
    testCompile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    testCompile 'com.github.Slyce-Inc:SlyceMessaging:1.1.2'
}
apply plugin: 'com.google.gms.google-services'

和 firebase 控制台。

在此处输入图像描述

我该如何解决?

请注意,json 个文件都是他们的项目之一。

我面临同样的错误。 我正在使用多种口味。 因此,我将google-services.json放在app/src/{flv}目录中。

它适用于一种口味,但不适用于其他口味。 问题是我还在应用程序目录中放置了与风味相对应的google-services.json

仅当在应用程序目录中没有找到google-services.json ,Google 才会搜索子目录/风味目录。

因此,请确保不要将google-services.json放在应用程序目录中,以防您为多种风格设置了单独的google-services.json

有关 Android 产品风格的模式详细信息,请参阅此文章

  1. 只需转到 google-services.json
  2. 将 package-name 更改为您的包的名称
{
  "client_info": {
    "mobilesdk_app_id": "1:113908578702:android:a0a98decfd9f22466f4cdf",
    "android_client_info": {
      "package_name": "com.example.Appname"
    }
  }
}
  1. 同步你的项目,它会被解决

我遇到了同样的问题,因此使用 Android Studio 2.3.3我使用了菜单Tools > Firebase - 在窗口右侧单击Notifications然后在您的应用程序上接收通知,最后单击Connect to Firebase ,之后您将看到对话框说此应用程序已连接到项目,但只需单击Sync ,然后 firebase 将自动同步您的所有应用程序客户端,它将解决此问题,顺便说一下,我知道现在响应为时已晚,但它可能会对某人有所帮助。

如果您添加了google-service.json文件,请检查 bulid.gradle(: app) package_name和 google-service.json 文件中的package_name是否相同
此外,如果您添加了productFlavors,请确保您已在 firebase 中添加该包以创建 JSON 文件

检查您的 Gradle 应用程序级 applicationId,它应该与 firebase 包名称相同,然后它就像一个魅力

*转到build.gradle并更改与AndroidManifest.xml相同的包名称并再次同步* [1][在此图像中显示AndroidManifest中的包名称与build.gradle相同] [1]:https://i.stack .imgur.com/T4cqz.png [下图显示 build.gradle 中的包名与 AndroidManifest 相同] [2]: https://i.stack.imgur.com/ModHS.png [build.gradle 中的包名][ 2]

还要检查 firebase 并下载最近的 .json 文件。

在应用级 gradle 文件的 defaultConfig 中更新您的 applicationId。 用你的包名。

尝试下载最新的google-services.json文件

有点晚了,但也许它可以帮助像我这样遇到同样情况的人。 我在项目设置的 Firebase 控制台中定义了另一个应用程序,其名称与我的其他风格构建不同,名称为 package。 然后我下载了新的 google-services.json 文件并使用了它。它对我来说就像一个魅力

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM