![](/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.