我正在尝试按照Google提供here的示例将我的Google Play服务依赖项升级到8.4.0,但我收到以下错误(' com.example.exampleapp' is替换我的应用程序包名称):
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.exampleapp'
Project 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 ...我会做的就是这是目前唯一可行的......
答案 0 :(得分:165)
"client": [
{
"client_info": {
"mobilesdk_app_id": "9:99999999:android:9ccdbb6c1ae659b8",
"android_client_info": {
"package_name": "[packagename]"
}
}
package_name
必须与您的清单文件中的内容相匹配。如果您查看下面的示例照片,可以找到google-services.json
文件。
答案 1 :(得分:95)
答案 2 :(得分:37)
答案 3 :(得分:20)
解决了获得异常的问题
java.lang.IllegalStateException:默认的FirebaseApp不是 在此过程中初始化确保调用 首先是FirebaseApp.initializeApp(上下文)。
在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"
....
答案 4 :(得分:18)
只有在我尝试构建调试版本类型时,才会发生同样的错误。我解决它的方法是为我的调试版本类型更改我的google-services.json
。
我的原始字段有一个名为client_id
的字段,值为android:com.example.exampleapp
,我刚刚删除了android:
前缀并保留为com.example.exampleapp
,之后我的gradle构建成功。
希望它有所帮助!
修改强>
我刚刚在android:
中添加了google-services.json
前缀,它继续正常运行。不确定究竟发生了什么,但我能够用上面提到的解决方案解决我的问题。
答案 5 :(得分:15)
用于修复:
找不到包名称' com.example.exampleapp:
的匹配客户
您应该从here
获取包的有效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'
答案 6 :(得分:6)
在android studio中打开google-services.json 我们可以看到一个json对象,并在' client'中包含以下项目。 jsonarray
" client_id":" android:您的包名", " package_name":"您的包名",
请验证您的包装并继续。
答案 7 :(得分:5)
我使用此配置找到了成功:
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
答案 8 :(得分:5)
当我的软件包名称未在我下载的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
答案 9 :(得分:5)
您的 google-services.json 软件包名称必须与 build.gradle applicationId(applicationId“您的软件包名称”)相匹配
答案 10 :(得分:3)
我有同样的问题,只是轻松解决它确保manifest.xml文件中mainfest标签中的包的包名称和gradle app level文件中的application标签中的applicationId具有相同的包名称
manifest.xml中的
package="com.example.work"
在gradle app level中
applicationId "com.example.work"
希望有所帮助
答案 11 :(得分:3)
检查您的“google-services.json”文件中的package_name是否可用
答案 12 :(得分:3)
如果在重命名您的应用程序包名称之后发生这种情况,那么您需要更新以下内容:
通过在文件中查找“package_name”属性,在应用程序中1) google-services.json 文件,并使用新的软件包名称进行更新。
2)在 Google Developers Console 中更新您的应用程序客户端凭据,方法是转到Credentials
并选择您的Android客户端密钥,然后更新新的软件包名称。
希望这会有所帮助。
答案 13 :(得分:1)
我认为因为您正在使用播放服务8.4.0
需要
classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
classpath 'com.google.gms:google-services:2.0.0-alpha5'
您也可以参考this。
答案 14 :(得分:1)
只需安装Android工作室&#39;以管理员身份运行&#39;它会起作用
或在 google-services.json 文件
上验证您的包名称答案 15 :(得分:1)
当我的软件包名称未在我下载的google-services.json文件中显示时,发生了这种情况。打开google-services.json文件,确保有一个client_info对象,其包名称与您的清单包名称相对应。
确保项目清单中的包名称在 google-services.json 文件中完全相同
感谢。
答案 16 :(得分:1)
对我来说,我必须检查google-services.json
文件并确保"package_name"
已正确设置为我的Android应用程序的包名称。在我的情况下,自动生成的服务文件附加了.backend
。
答案 17 :(得分:0)
请验证build.gradle.
defaultConfig {
applicationId "<packagename>"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
验证包名。它也可能导致错误。
答案 18 :(得分:0)
两次编写包名称时: 1.在Android Studio中创建新项目时 和 2.创建配置文件时
你应该用小写字母写它 - 在改为小写后它起作用。如果你不想浪费时间,只需转到.json文件并用com.myname.myapplicationname替换com.myname.MyAPPlicationnamE(对于json文件中的每个匹配项)。
答案 19 :(得分:0)
在上面研究清单文件中的包名称和gradle构建文件中的应用程序ID应该是相同的。我的问题没有解决。
实际上,gradle构建文件中的应用程序ID应与google-services.json文件中的程序包名称相同。如果您的google-services.json文件具有不同的包名称。从谷歌分析或firebase控制台删除该应用程序。并获得一个新文件。
答案 20 :(得分:0)
答案 21 :(得分:0)
在我的情况下,我只需要做
答案 22 :(得分:0)
1)检查包名称在google-services.json文件中是否相同
2)确保没有其他具有相同程序包名称的项目
3)确保可以访问互联网
4)尝试同步项目并再次运行