【问题标题】:Error: Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package name 'com.xx.xxx.xxxx'错误:任务“:app:processDebugGoogleServices”执行失败。 > 找不到与包名称 'com.xx.xxx.xxxx' 匹配的客户端
【发布时间】:2018-11-14 20:21:46
【问题描述】:

我尝试将我的项目与 Gradle 文件同步时出错

这是错误

错误:任务 ':app:processDebugGoogleServices' 执行失败。不 为包名称“com.xx.xxx.xxxx”找到匹配的客户端

这是我的 Gradle 文件内容:

apply plugin: 'com.android.application'

apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 26
buildToolsVersion '27.0.3'

defaultConfig {
    applicationId "com.xx.xxx.xxxx"
    minSdkVersion 19
    targetSdkVersion 22
    versionCode 1
    versionName "1.0.3"
    testInstrumentationRunner  "android.support.test.runner.AndroidJUnitRunner"
    useLibrary 'org.apache.http.legacy'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {

compile 'com.android.support:support-v4:26.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:26.1.0'

compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'

compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.jakewharton:butterknife:7.0.1'
provided 'org.projectlombok:lombok:1.12.6'
compile 'org.parceler:parceler-api:1.0.4'
apt 'org.parceler:parceler:1.0.4'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.maps:google-maps-services:0.2.5'
compile 'org.slf4j:slf4j-nop:1.7.25'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.cocosw:bottomsheet:1.+@aar'
}

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

我已经检查了我的 google-service 文件包名称和应用程序 ID,两者都是相同的,但是当我尝试构建应用程序时,发生了上述错误。我的 google-services 文件包含多个项目,包括这个。

请帮我解决它。

【问题讨论】:

  • 如果对你有帮助,请查看我的回答,如果你也提供和 app grandle 那就太好了
  • 签出我给出的简单解决方案,希望对您有所帮助

标签: android firebase push-notification google-cloud-messaging


【解决方案1】:

只需转到 Firebase 控制台并创建新项目并使用所需的 com.xx.xxx.xxxx 包名称添加一个新应用程序,然后针对该包名称获取 google-services.json 文件,然后将该文件添加到您的应用程序模块并重新构建,或者如果您不这样做'不想添加 .json 文件,然后只需从您的 gradle 文件中删除 apply plugin: 'com.google.gms.google-services' 并再次构建您的项目。

【讨论】:

    【解决方案2】:

    首先去android/app/build.gradle搜索applicationId(在androiddefaultConfig内)

    并确保该值与 this 相同

    client[0]client_info.android_client_info.package_name

    作为google-services.json中的值。

    然后,尝试更新 Project grandle(到最新版本),如下所示:

    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.google.gms:google-services:4.0.1'
    

    还更新 firebase 依赖项,例如(选择您需要的),这是基于最新版本 of this link:

        implementation 'com.google.firebase:firebase-core:16.0.0'
        implementation 'com.google.firebase:firebase-ads:15.0.1'
        implementation 'com.google.firebase:firebase-analytics:16.0.0'
        implementation 'com.google.firebase:firebase-appindexing:15.0.1'
        implementation 'com.google.firebase:firebase-auth:16.0.1'
        implementation 'com.google.firebase:firebase-firestore:17.0.1'
        implementation 'com.google.firebase:firebase-functions:16.0.1'
        implementation 'com.google.firebase:firebase-messaging:17.0.0'
        implementation 'com.google.firebase:firebase-storage:16.0.1'
        implementation 'com.google.firebase:firebase-crash:16.0.0'
        implementation 'com.google.firebase:firebase-invites:16.0.0'
        implementation 'com.google.firebase:firebase-perf:16.0.0'
        implementation 'com.google.firebase:firebase-database:16.0.1'
        implementation 'com.google.firebase:firebase-config:16.0.0'
    

    这是基于this link的大应用程序文件,(选择你需要的):

    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    

    【讨论】:

    • @ClickSolApps 所以你有同样的问题,这不起作用?
    猜你喜欢
    • 2021-06-20
    • 2016-06-22
    • 2016-04-13
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 1970-01-01
    • 2019-06-19
    • 1970-01-01
    相关资源
    最近更新 更多