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

时间:2018-06-05 11:04:52

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

当我尝试使用Gradles文件同步项目时出现错误

这是错误

  

错误:任务':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文件包含多个项目,包括此项目。

请帮我修理一下。感谢。

2 个答案:

答案 0 :(得分:0)

首先,转到android/app/build.gradle并搜索applicationId(在androiddefaultConfig内)

并确保该值与此

相同

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

的grandle app文件,(选择你需要的)
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'

答案 1 :(得分:0)

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