Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio
Error: Could not find com.google.gms:google-services:1.0. when adding google service plugin in build.gradle in android studio
我正在我的 android 应用程序中集成 Google+ 的 OAuth 登录,遵循 tutorial.
根据教程,我应该通过添加 Google 服务插件来添加
classpath 'com.google.gms:google-services:1.0'
依赖于我的 android 项目中的顶级 build.gradle
。
但是,当我将 gradle 与更改同步时,我看到如下错误:
Error:Could not find com.google.gms:google-services:1.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.jar
在我的 build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
android 工作室似乎无法从存储库中找到 google-services 插件。
有人遇到同样的问题吗?或者,我错过了什么吗?
您可能错过了这一步
将刚刚下载的 google-services.json 文件复制到 Android Studio 项目的 app/ 或 mobile/ 目录中。打开 Android Studio 终端面板:
$ 移动 path-to-download/google-services.json 应用程序/
玩得开心。
我 运行 今天遇到了同样的问题。在样本中,他们改用这一行:
classpath 'com.google.gms:google-services:1.3.0-beta1'
这行得通。
我在遵循 instructions 在 Android Studio 中实现 GCM 客户端时遇到了类似的问题,但是,我收到的消息是:
Error: Could not find com.google.gms:google-services:1.3.0-beta1...
虽然我从未弄清楚哪里出了问题,但我只是将我的源代码、资源、清单和密钥库复制到一个新的 Android Studio 项目中。然后我通过手动重新添加我的依赖项来为新项目编辑自动生成的 gradle 构建文件。
我确保没有从旧项目中逐字复制我的构建文件(因为错误的来源可能在它们的某个地方)。
这不是一个令人满意的解决方案,但它对我有用,而且花费的时间很少。
Google 已更新 their guide。它是类路径 'com.google.gms:google-services:1.0' 现在读取类路径 'com.google.gms:google-services:1.3.0-beta1' 就像 joluet 建议的那样。
对我来说,我不得不将存储库切换到 jcenter()
。我正在使用 mavenCentral 并收到此错误。我一切换到 jcenter()
,它就降低了依赖性。
为此,请打开您的 build.gradle
并将 mavenCentral()
的每个实例替换为 jcenter()
您应该将类路径“com.google.gms:google-services:1.3.0-beta1
”添加到您的 (Top level build file)
的 dependencies
和具有 (Project:<name of your project)
的 build.gradle
。希望这对您有所帮助!
您需要检查当前版本,如下面 link 中所述,现在:
classpath 'com.google.gms:google-services:1.3.0-beta4'
检查这个答案:
Google现已发布插件v1.3.0
我能够使用 this:
解决它
classpath 'com.google.gms:google-services:1.3.0'
我建议你不要做你正在做的事情。我也这样做了(通过盲目地遵循 Set up a GCM Client App on Android)但最终超过了 65K 方法限制。
因此,您应该从 gradle 中删除以下行:
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'
现在导入 Google 的 API Plus,只需 gradle 导入:
compile 'com.google.android.gms:play-services-plus:8.1.0'
我想你忘记了gradle的项目级别,
将依赖项添加到您的 项目级别 build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'
将插件添加到您的 app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
我们必须寻找在我的案例中的最后一个版本是:
dependencies {
classpath 'com.google.gms:google-services:1.4.0-beta3'
}
Here 您可以找到版本列表。
截至 2015 年 11 月 25 日,google 发布了较新的版本。
尝试添加:
classpath 'com.google.gms:google-services:2.0.0-alpha1'
并且不要忘记在 buildscript 下添加 jcenter()
存储库。
谢谢。
我通过执行以下操作解决了这个问题:
在build.gradle中(在项目级别):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
allprojects {
repositories {
mavenCentral()
}
}
在build.gradle中(在模块级别):
在顶部添加:
apply plugin: 'com.google.gms.google-services'
并在依赖项中添加:
compile 'com.google.android.gms:play-services-analytics:8.3.0'
除此之外,请确保您已更新 SDK 中的 Google Play 服务和 Google 存储库。
将 jcenter 存储库添加到项目级别 build.gradle 对我的情况有所帮助:
buildscript {
repositories {
jcenter();
mavenCentral()
}
Google 已更新 GCM 去检查一下,为此你还必须更新你的 Android Studio。
在 .idea folder
中存在一个定义 project's structure
的 workspace.xml 文件。我建议您关闭 Android Studio,然后 delete .idea folder
然后再次导入项目。 .idea 将再次由 IDE 生成。对我来说,这个解决方案有效。
当我遇到这个问题时,我正在尝试为我的 android 应用程序设置 firebase。以下屏幕截图应该澄清一些事情 -
我想指出几件事 -
1. 一旦你
apply plugin: 'com.google.gms.google-services'
此行应位于应用级别 gradle 文件的底部。不知道为什么,但放在顶部对我来说没有锻炼。
对我来说,在 dependencies
下添加这个有效
compile 'com.google.gms:google-services:3.0.0'
如果您使用 Android Studio,请尝试使用 IDE 添加 google 服务。
- 右键单击文件夹模块。
- 在
Developer Services
的左侧列表中选择所需的服务。
- 等待同步,IDE会自动添加google个依赖。
在 buildscript
上添加 classpath
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
我最近更新到 Android Studio 2.3,但不知何故应用插件不起作用。
之后,我尝试了各种方法,然后注释掉应用程序的build.gradle:
apply plugin: 'com.google.gms.google-services'
然后我将其添加到顶级 build.gradle(在 类路径 'com.android.tools.build:gradle:2.2.3' 下方):
classpath 'com.google.gms:google-services:3.0.0'
然后就可以了。
我正在我的 android 应用程序中集成 Google+ 的 OAuth 登录,遵循 tutorial.
根据教程,我应该通过添加 Google 服务插件来添加
classpath 'com.google.gms:google-services:1.0'
依赖于我的 android 项目中的顶级 build.gradle
。
但是,当我将 gradle 与更改同步时,我看到如下错误:
Error:Could not find com.google.gms:google-services:1.0.
Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.pom file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/1.0/google-services-1.0.jar https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.pom https://jcenter.bintray.com/com/google/gms/google-services/1.0/google-services-1.0.jar
在我的 build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
android 工作室似乎无法从存储库中找到 google-services 插件。
有人遇到同样的问题吗?或者,我错过了什么吗?
您可能错过了这一步
将刚刚下载的 google-services.json 文件复制到 Android Studio 项目的 app/ 或 mobile/ 目录中。打开 Android Studio 终端面板: $ 移动 path-to-download/google-services.json 应用程序/
玩得开心。
我 运行 今天遇到了同样的问题。在样本中,他们改用这一行:
classpath 'com.google.gms:google-services:1.3.0-beta1'
这行得通。
我在遵循 instructions 在 Android Studio 中实现 GCM 客户端时遇到了类似的问题,但是,我收到的消息是:
Error: Could not find com.google.gms:google-services:1.3.0-beta1...
虽然我从未弄清楚哪里出了问题,但我只是将我的源代码、资源、清单和密钥库复制到一个新的 Android Studio 项目中。然后我通过手动重新添加我的依赖项来为新项目编辑自动生成的 gradle 构建文件。
我确保没有从旧项目中逐字复制我的构建文件(因为错误的来源可能在它们的某个地方)。
这不是一个令人满意的解决方案,但它对我有用,而且花费的时间很少。
Google 已更新 their guide。它是类路径 'com.google.gms:google-services:1.0' 现在读取类路径 'com.google.gms:google-services:1.3.0-beta1' 就像 joluet 建议的那样。
对我来说,我不得不将存储库切换到 jcenter()
。我正在使用 mavenCentral 并收到此错误。我一切换到 jcenter()
,它就降低了依赖性。
为此,请打开您的 build.gradle
并将 mavenCentral()
的每个实例替换为 jcenter()
您应该将类路径“com.google.gms:google-services:1.3.0-beta1
”添加到您的 (Top level build file)
的 dependencies
和具有 (Project:<name of your project)
的 build.gradle
。希望这对您有所帮助!
您需要检查当前版本,如下面 link 中所述,现在:
classpath 'com.google.gms:google-services:1.3.0-beta4'
检查这个答案:
Google现已发布插件v1.3.0
我能够使用 this:
解决它classpath 'com.google.gms:google-services:1.3.0'
我建议你不要做你正在做的事情。我也这样做了(通过盲目地遵循 Set up a GCM Client App on Android)但最终超过了 65K 方法限制。
因此,您应该从 gradle 中删除以下行:
apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'
现在导入 Google 的 API Plus,只需 gradle 导入:
compile 'com.google.android.gms:play-services-plus:8.1.0'
我想你忘记了gradle的项目级别,
将依赖项添加到您的 项目级别 build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'
将插件添加到您的 app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
我们必须寻找在我的案例中的最后一个版本是:
dependencies {
classpath 'com.google.gms:google-services:1.4.0-beta3'
}
Here 您可以找到版本列表。
截至 2015 年 11 月 25 日,google 发布了较新的版本。
尝试添加:
classpath 'com.google.gms:google-services:2.0.0-alpha1'
并且不要忘记在 buildscript 下添加 jcenter()
存储库。
谢谢。
我通过执行以下操作解决了这个问题:
在build.gradle中(在项目级别):
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.google.gms:google-services:1.5.0-beta2' } } allprojects { repositories { mavenCentral() } }
在build.gradle中(在模块级别):
在顶部添加:
apply plugin: 'com.google.gms.google-services'
并在依赖项中添加:
compile 'com.google.android.gms:play-services-analytics:8.3.0'
除此之外,请确保您已更新 SDK 中的 Google Play 服务和 Google 存储库。
将 jcenter 存储库添加到项目级别 build.gradle 对我的情况有所帮助:
buildscript {
repositories {
jcenter();
mavenCentral()
}
Google 已更新 GCM 去检查一下,为此你还必须更新你的 Android Studio。
在 .idea folder
中存在一个定义 project's structure
的 workspace.xml 文件。我建议您关闭 Android Studio,然后 delete .idea folder
然后再次导入项目。 .idea 将再次由 IDE 生成。对我来说,这个解决方案有效。
当我遇到这个问题时,我正在尝试为我的 android 应用程序设置 firebase。以下屏幕截图应该澄清一些事情 -
我想指出几件事 - 1. 一旦你
apply plugin: 'com.google.gms.google-services'
此行应位于应用级别 gradle 文件的底部。不知道为什么,但放在顶部对我来说没有锻炼。
对我来说,在 dependencies
下添加这个有效
compile 'com.google.gms:google-services:3.0.0'
如果您使用 Android Studio,请尝试使用 IDE 添加 google 服务。
- 右键单击文件夹模块。
- 在
Developer Services
的左侧列表中选择所需的服务。 - 等待同步,IDE会自动添加google个依赖。
在
上添加buildscript
classpath
buildscript { repositories { jcenter() } dependencies { classpath 'com.google.gms:google-services:1.3.0-beta1' } }
我最近更新到 Android Studio 2.3,但不知何故应用插件不起作用。
之后,我尝试了各种方法,然后注释掉应用程序的build.gradle:
apply plugin: 'com.google.gms.google-services'
然后我将其添加到顶级 build.gradle(在 类路径 'com.android.tools.build:gradle:2.2.3' 下方):
classpath 'com.google.gms:google-services:3.0.0'
然后就可以了。