【问题标题】:No matching client found for package name 'demo.abc.com.deals.debug'找不到与包名称“demo.abc.com.deals.debug”匹配的客户端
【发布时间】:2017-06-27 12:47:48
【问题描述】:

我正在努力使用 android 应用登录谷歌。 我按照给定链接Google Sign-In for Android 中的步骤操作我创建了google-services.json 文件,该文件具有相同的应用程序ID/包名称,该文件位于AndroidMenifest.xml 文件中。请快速检查下面的AndroidMenifest.xml 代码以及google-services.json 文件。

AndroidMenifest.xml

<?xml version="1.0" encoding="utf-8"?>
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        package="demo.abc.com.deals">
        <uses-sdk tools:overrideLibrary="com.facebook" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE"  />
        <application
        android:name=".ParityApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <activity
            android:name="com.facebook.FacebookActivity"
            android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            />
        <activity
            android:name=".views.splash.SplashActivity"
            android:configChanges="keyboard|orientation|screenSize"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".MainActivity"
            android:configChanges="keyboard|orientation|screenSize"
            android:exported="false"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateHidden|adjustPan" />

    </application>

</manifest>

google-services.json

"client_info": {
    "mobilesdk_app_id": "1:216768689126:android:64277ad0e8ef7db8",
    "android_client_info": {
      "package_name": "demo.abc.com.deals"
    }

build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "demo.abc.com.deals"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
    enabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
    mavenCentral()
}
buildTypes {
    debug {
        debuggable true
        applicationIdSuffix '.debug'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        resValue 'string', 'app_name', 'Parity-SIT'
    }
    uat.initWith(buildTypes.debug)
    uat {
        applicationIdSuffix '.uat'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        resValue 'string', 'app_name', 'Parity-UAT'
    }
    release {
        minifyEnabled false
        resValue 'string', 'app_name', 'Parity'
        buildConfigField("String", "SCHEME", "\"http:\"")
        buildConfigField("String", "AUTHORITY", "\"//139.162.46.29\"")
        buildConfigField("String", "SERVER_URL", "\"http://139.162.46.29/v3\"")
        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:design:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-annotations:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.18.0'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'me.tatarka.retrolambda'

项目级 build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'me.tatarka:gradle-retrolambda:3.6.0'
    classpath 'com.google.gms:google-services:3.0.0'

}

在所有三个文件中,包名都是demo.abc.com.deals,但我仍然收到此错误。

错误:任务 ':app:processDebugGoogleServices' 执行失败。 找不到与包名称“demo.abc.com.deals.debug”匹配的客户端。

我尝试了关于 SO 在此处提出的同一问题的所有建议,但甚至没有一个解决方案对我有用。 我真的可以利用所有 SO 用户的建议和经验来处理这个问题。

google-services.json 文件添加目录结构

【问题讨论】:

  • 你能发布你的 gradle 文件吗
  • 你可以发布项目级别的gradle文件
  • @Anil,请检查已编辑问题中的项目级别build.gradle 文件。
  • 我能得到你粘贴 json 文件的屏幕截图吗
  • 使用这个 compile 'com.google.android.gms:play-services-auth:11.0.1' 而不是 compile 'com.google.android.gms:play-services:9.0.0'

标签: android build.gradle google-signin google-play-services


【解决方案1】:

最后,我在将谷歌登录集成到我的应用程序时解决了这个问题, 当我尝试为我的应用设置 google 登录时,我在应用级别 build.gradle 文件中添加了 3 个构建变体。

当我为每种构建类型添加google-services.json 时,它工作正常,app/src 文件夹中应该有一致的导演。在相应的构建变体文件夹中添加google-services.json 文件后,请查看下面的 dir 结构屏幕截图。

临时更改

在所有 google-services.json 文件中,您应该根据构建类型指定正确的 package_name。

比如,在调试目录里面应该是"package_name": "demo.abc.com.deals.debug"

【讨论】:

  • 谢谢!在找到这个可行的答案之前,我也搜索了所有内容!
  • @RayLi,如果这个答案对您有帮助,请接受它作为答案。谢谢!
  • 什么意思?您提出并回答了这个问题,所以只有您可以接受这个作为答案;)
  • @RayLi,我的意思是只投票赞成这个答案。谢谢!
【解决方案2】:

在 gradle 底部添加以下代码

apply plugin: 'com.google.gms.google-services'

喜欢这个

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:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.firebase:firebase-auth:11.0.1'
    compile 'com.google.android.gms:play-services-auth:11.0.1'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'


}
apply plugin: 'com.google.gms.google-services'

【讨论】:

  • 我试过了,但没有工作,我仍然收到同样的错误。
  • 你可以发布项目级别的 grdle
  • 编译已过时,您需要改用Implementation
猜你喜欢
  • 2019-06-19
  • 2020-10-19
  • 2019-01-13
  • 1970-01-01
  • 1970-01-01
  • 2021-10-08
  • 2018-06-14
相关资源
最近更新 更多