![](/img/trans.png)
[英]Error: Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package name 'com.xx.xxx.xxxx'
[英]Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package
我正在尝试按照 Google 在此处提供的示例将我的 google play 服务依赖项升级到 8.4.0,但出现以下错误(“com.example.exampleapp”是我的应用程序包名称的替代):
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.exampleapp'
项目 build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
模块 app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.exampleapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
useLibrary 'org.apache.http.legacy'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.exoplayer:exoplayer:r1.5.2'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar') {
transitive = true
}
compile files('libs/commons-lang3-3.3.2.jar')
}
apply plugin: 'com.google.gms.google-services'
gradle-wrapper.properties:
#Fri Jan 01 08:23:56 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
关于为什么 gradle 无法识别我自己的应用程序包名称的任何想法?
编辑:
好的,这次我遇到了不同的错误。
根据 Shawn Thye 提供的链接,我将其添加到 app/build.gradle 的底部:
apply plugin: 'com.google.gms.google-services'
并留下我之前列出的所有其他内容,我收到了这个错误:
Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
/Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle
Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
Information:BUILD FAILED
Information:Total time: 0.921 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
和 Gradle 控制台:
Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.211 secs
所以,然后我按照要求将 gradle-wrapper.properties 更改为“gradle-2.10-all”并收到此错误:
Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
please apply google-services plugin at the bottom of the build file.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library
:app:prepareComAndroidSupportCardviewV72311Library
:app:prepareComAndroidSupportDesign2311Library
:app:prepareComAndroidSupportGridlayoutV72311Library
:app:prepareComAndroidSupportRecyclerviewV72311Library
:app:prepareComAndroidSupportSupportV42311Library
:app:prepareComDigitsSdkAndroidDigits192Library
:app:prepareComFacebookAndroidFacebookAndroidSdk470Library
:app:prepareComGoogleAndroidExoplayerExoplayerR152Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
:app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
:app:prepareComTwitterSdkAndroidTweetComposer102Library
:app:prepareComTwitterSdkAndroidTweetUi180Library
:app:prepareComTwitterSdkAndroidTwitter1110Library
:app:prepareComTwitterSdkAndroidTwitterCore162Library
:app:prepareIoFabricSdkAndroidFabric1310Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:processDebugManifest
:app:fabricGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.
Information:BUILD FAILED
Information:Total time: 5.724 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
和 Gradle 控制台:
Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
Configuration on demand is an incubating feature.
google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
please apply google-services plugin at the bottom of the build file.
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library
:app:prepareComAndroidSupportCardviewV72311Library
:app:prepareComAndroidSupportDesign2311Library
:app:prepareComAndroidSupportGridlayoutV72311Library
:app:prepareComAndroidSupportRecyclerviewV72311Library
:app:prepareComAndroidSupportSupportV42311Library
:app:prepareComDigitsSdkAndroidDigits192Library
:app:prepareComFacebookAndroidFacebookAndroidSdk470Library
:app:prepareComGoogleAndroidExoplayerExoplayerR152Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
:app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
:app:prepareComTwitterSdkAndroidTweetComposer102Library
:app:prepareComTwitterSdkAndroidTweetUi180Library
:app:prepareComTwitterSdkAndroidTwitter1110Library
:app:prepareComTwitterSdkAndroidTwitterCore162Library
:app:prepareIoFabricSdkAndroidFabric1310Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:processDebugManifest
:app:fabricGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.724 secs
它要求在构建文件底部的 google-services 插件,它已经是,它要求我再次运行 8.3.0 ......我会这样做,因为这是现在唯一可以工作的......
解决了获取异常的问题
java.lang.IllegalStateException:在此过程中未初始化默认 FirebaseApp 确保首先调用 FirebaseApp.initializeApp(Context)。
在 FirebaseInstanceId.getInstance().getToken()
检查package_name 是否与applicationId完全匹配 1) build.gradle
defaultConfig {
applicationId "build.gradle.exactly.matches.json"
...
}
应该完全匹配 2) google-services.json
{
"client_info": {
"mobilesdk_app_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"android_client_info": {
"package_name": "build.gradle.exactly.matches.json"
....
仅当我尝试构建调试构建类型时,才发生完全相同的错误。 我解决它的方法是将我的google-services.json
更改为我的调试构建类型。 我的原始字段有一个名为client_id
的字段,其值为android:com.example.exampleapp
,我刚刚删除了android:
前缀并保留为com.example.exampleapp
,之后我的 gradle 构建成功。
希望能帮助到你!
编辑
我刚刚在google-services.json
重新添加了android:
前缀,它继续正常工作。 不确定到底发生了什么,但我能够用上面提到的解决方案解决我的问题。
用于固定:
找不到与包名称“com.example.exampleapp”匹配的客户端:
你应该从这里为你的包获得一个有效的google-service.json
文件
用于固定:
请通过更新 google-services 插件的版本来修复版本冲突(有关最新版本的信息可在https://bintray.com/android/android-tools/com.google.gms.google-services/ 获得)或将 com.google.android.gms 的版本更新为 8.3.0.:
您应该将apply plugin: 'com.google.gms.google-services'
到应用gradle.build
文件的末尾。 像这样的东西:
dependencies {
...
}
apply plugin: 'com.google.gms.google-services'
在 android studio 中打开 google-services.json 我们可以看到一个 json 对象,并且在 'client' jsonarray 中包含以下项目
"client_id": "android:你的包名", "package_name": "你的包名",
请验证您的包裹并继续。
我发现使用此配置成功:
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
//or use
//classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
和
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
使用 8.40 Google Play 服务。 Alpha5 和 Alpha6 给出了与您相同的 2.8 错误,无论 distributionUrl 为 2.10
当我下载的 google-services.json 文件中没有表示我的包名称时,这发生在我身上。 打开您的 google-services.json 文件并确保有一个 client_info 对象的包名称与您的清单包名称相对应。
在 googleservices.json 中:
"client": [
{
"client_info": {
"mobilesdk_app_id": "my-app-id",
"android_client_info": {
"package_name": "com.me.android.test.myapp"
}
并在您的清单中:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.android.test.myapp" >
您可能需要为您的项目重新创建一个新的 google-services.json,您可以在此处创建: https : //developers.google.com/mobile/add?platform=android&cntapi=gcm
您的google-services.json包名称必须与您的build.gradle applicationId 匹配(applicationId“您的包名称”)
如果在重命名应用程序包名称后发生这种情况,则需要更新以下内容:
1) 在您的应用程序中查找google-services.json文件,方法是在文件中查找“package_name”属性并使用新的包名称更新它。
2) 在Google Developers Console 中更新您的应用程序客户端凭据,方法是转到Credentials
并选择您的 android 客户端密钥,然后使用新的包名称更新包名称。
希望这会有所帮助。
检查,在您的“google-services.json”文件中,您的 package_name 是否可用
我有同样的问题,只是简单地解决它确保 manifest.xml 文件中 mainfest 标签中的包的包名称和 gradle 应用程序级别文件中的应用程序标签中的 applicationId 具有相同的包名称
在 manifest.xml 中
package="com.example.work"
在 gradle 应用程序级别
applicationId "com.example.work"
希望它有帮助
1) 检查 google-services.json 文件中的包名称是否相同
2)确保不存在具有相同包名的其他项目
3)确保有互联网访问
4)尝试同步项目并再次运行它
在项目gradle文件中添加这个
classpath 'com.google.gms:google-services:3.0.0'
我想是因为您使用的是 play-service 8.4.0
它需要
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
classpath 'com.google.gms:google-services:2.0.0-alpha5'
你也可以参考这个。
对我来说,我必须检查google-services.json
文件并确保"package_name"
正确设置为我的 android 应用程序的包名称。 在我的例子中,自动生成的服务文件附加了.backend
。
当我下载的 google-services.json 文件中没有表示我的包名称时,这发生在我身上。 打开您的 google-services.json 文件并确保有一个 client_info 对象的包名称与您的清单包名称相对应。
确保项目清单中的包名称与google-services.json文件中的完全相同
谢谢。
只需 Android Studio 运行“以管理员身份运行”即可
或者在google-services.json文件中验证您的包名称
经过上面的研究,清单文件中的包名和gradle构建文件中的应用程序ID应该相同。 我的问题没有解决。
实际上,您在 gradle 构建文件中的应用程序 ID 应该与您在 google-services.json 文件中的包名称相同。 如果您的 google-services.json 文件具有不同的包名称。 从谷歌分析或 Firebase 控制台中删除该应用程序。 并获得一个新文件。
请验证build.gradle.
defaultConfig {
applicationId "<packagename>"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
验证包名称。它也可能导致错误。
两次写入包名称时: 1. 在 Android Studio 中创建新项目时和 2. 创建配置文件时
你应该用小写字母写它 - 更改为小写后它可以工作。 如果您不想浪费时间,只需转到 .json 文件并将 com.myname.MyAPPlicationnamE 替换为 com.myname.myapplicationname(对于 json 文件中的每个匹配项)。
就我而言,我只需要做
然后一切都很顺利。 我仍然不知道发生了什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.