找不到与包名称"...."匹配的客户端.具有不同的buildvariant [英] No matching client found for package name "...." with different buildvariant

查看:127
本文介绍了找不到与包名称"...."匹配的客户端.具有不同的buildvariant的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want o implement push notification. I added to project level:

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

并进入应用程序级别:(在文件底部)

and to app level:(at the bottom of the file)

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

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

Then I added google-services.json file to project in app level

但是,当我同步gradle时,它会引发错误:

But, when I syncro gradle, it launch the error:

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

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

In gradle I have 2 different build variants , and look like:

清单:

<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控制台.

And the firebase console.

我该如何解决?

请注意,json文件是它们的每个项目之一.

Note, that json files are each one of their project.

推荐答案

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

I was facing the same error. I am using multiple flavors. Therefore, I put the google-services.json in app/src/{flv} directory.

它对一种口味有效,但对其他口味无效.问题是我还把与google-services.json相对应的google-services.json放置在应用程序目录中.

It worked well for one flavor but did not work for others. The issue was that I have also placed google-services.json corresponding to flavor for which it was working in app directory also.

仅当在应用目录中未找到google-services.json时,Google才会搜索子目录/flavor目录.

Google will search for sub-directories / flavor directories only if it did not find the google-services.json in the app directory.

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

So, make sure you don't put google-services.json in app directory in case you have separate google-services.json for multiple flavors.

请参阅

Please see this article for mode details on Android product flavors.

这篇关于找不到与包名称"...."匹配的客户端.具有不同的buildvariant的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆