错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

时间:2022-01-08 15:18:10

I am integrating OAuth login for Google+ on my android application, following the tutorial.

在我的android应用程序中,我正在集成OAuth登录,以获得谷歌+。

According to the tutorial, I should add the Google Service plugin by adding classpath 'com.google.gms:google-services:1.0' dependency to top-level build.gradle in my android project.

根据本教程,我应该通过添加classpath的com.google.gms: Google -services:1.0对*构建的依赖来添加谷歌服务插件。我的android项目。

However, when I sync the gradle with the changes, I see the error as follows:

但是,当我将梯度与变化同步时,我发现错误如下:

Error:Could not find com.google.gms:google-services:1.0.

错误:找不到com.google.gms:谷歌服务: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

在以下位置搜索:file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/goog -services/1.0/google-services-1.0。pom文件:/ C:/程序文件/ Android / Android工作室/ gradle m2repository /com/google/gms/google - services/1.0/google -服务- 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

In my build.gradle:

在我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()
    }
}

It seems that the android studio is not able to find google-services plugin from repositories.

似乎android studio无法从存储库中找到google-services插件。

Does anybody have the same issue? Or, am I missing something?

有人有同样的问题吗?或者,我是不是漏掉了什么?

20 个解决方案

#1


73  

I ran into the same issue today. In the samples they use this line instead: classpath 'com.google.gms:google-services:1.3.0-beta1' This works.

我今天遇到了同样的问题。在这些示例中,他们使用了这一行:classpath的com.google.gms:google-services:1.3.0-beta1“这行得通。

#2


50  

For me I had to switch the repository to jcenter(). I was using mavenCentral and getting this error. As soon as I switched to jcenter() it pulled the dependency down.

对于我来说,我必须将存储库切换到jcenter()。我使用mavenCentral得到这个错误。当我切换到jcenter()时,它将依赖项拉下。

To do this, open your build.gradle and replace each instance of mavenCentral() with jcenter()

为此,打开您的构建。将mavenCentral()的每个实例替换为jcenter()

#3


13  

Google updated their guide. Where it was classpath 'com.google.gms:google-services:1.0' now reads classpath 'com.google.gms:google-services:1.3.0-beta1' like joluet suggested.

谷歌更新他们的指南。google. google.gms:google-services:1.0' now read classpath 'com.google.gms:google-services:1.3.0-beta1', joluet建议的。

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

#4


10  

Google now released the plugin v1.3.0

谷歌现在发布了插件v1.3.0

I was able to solve it using this:

我可以用这个解出来

classpath 'com.google.gms:google-services:1.3.0'

类路径的1.3.0 com.google.gms:谷歌服务:版本

#5


10  

I resolved this issue by doing the following things:

我通过以下几点来解决这个问题:

  1. In build.gradle (at project level):

    在构建。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()
        }
    }
    
  2. In build.gradle (at module level):

    在构建。gradle(在模块级):

    On top added:

    上面说:

    apply plugin: 'com.google.gms.google-services'
    

    and in dependecies added:

    而在dependecies补充道:

    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    

Apart from this make sure you have updated the Google Play services and Google repository in the SDK.

除此之外,请确保您已经在SDK中更新了谷歌Play服务和谷歌存储库。

#6


7  

As of 25th Nov,2015, google released a newer version.

截至2015年11月25日,谷歌发布了一个新版本。

Try adding: classpath 'com.google.gms:google-services:2.0.0-alpha1'

尝试添加:类路径com.google.gms:谷歌服务:2.0.0-alpha1”

And don't forget to add jcenter() repository under buildscript.

不要忘记在buildscript中添加jcenter()存储库。

Thanks.

谢谢。

#7


4  

I think you forgotten gradle's project level,

我想你忘了葛莱蒂的项目水平,

From developers page:

从页面开发人员:

Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'

将依赖项添加到项目级别的构建中。gradle类路径的com.google.gms:谷歌服务:1.5.0-beta2

Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'

将插件添加到应用程序级别的构建中。gradle:应用插件:“com.google.gms.google-services”

#8


4  

Google has updated GCM go check it and for that you have to update your Android Studio too.

谷歌已经更新了GCM go check它,为此你也必须更新你的Android Studio。

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

#9


3  

I would advise you against doing what you are doing. I did it too (by following Set up a GCM Client App on Android blindly) but ended up with exceeding 65K method limit.

我劝你不要做你正在做的事。我也这么做了(通过盲目地在Android上建立一个GCM客户端应用),但最终超过了65K的方法限制。

So, you should remove the following lines from your gradle:

所以,你应该从你的等级中删除以下几行:

apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'

Now import APIs of Google Plus with simple gradle import:

现在导入谷歌的api加上简单的gradle导入:

compile 'com.google.android.gms:play-services-plus:8.1.0'

#10


3  

Adding jcenter repository to project level build.gradle helped in my case:

将jcenter存储库添加到项目级别的构建中。葛莱蒂帮了我的忙:

buildscript {
    repositories {
        jcenter();
        mavenCentral()
    }

#11


1  

I was trying to setup firebase for my android app when I faced this problem. Following screenshot should clarify things -

当我遇到这个问题时,我正在为我的android应用程序安装firebase。下面的截图应该澄清一些事情

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

Couple of things I would like to point out - 1. Once you

我想指出的几点是- 1。一旦你

apply plugin: 'com.google.gms.google-services'

This line should be at the bottom of the app level gradle file. Not sure why but putting at the top did not workout for me.

这一行应该在应用程序级文件的底部。我不知道为什么,但把它放在最上面对我来说并不合适。

#12


1  

If you use Android Studio, try to add google service with the IDE.

如果您使用Android Studio,请尝试在IDE中添加谷歌服务。

  1. Right click on folder module.
  2. 右键单击文件夹模块。
  3. On left list at Developer Services choose desired service.
  4. 在开发人员服务的左侧列表中选择所需的服务。
  5. Wait for syncing and the IDE will automatically add google dependecies.
  6. 等待同步,IDE将自动添加谷歌依赖项。
  7. add classpath on buildscript

    buildscript上添加类路径

    buildscript { repositories { jcenter() } dependencies { classpath 'com.google.gms:google-services:1.3.0-beta1' } }

    {jcenter()}依赖项{classpath 'com.google.gms:google-services:1.3.0-beta1'}}

#13


0  

You maybe miss this step

你可能会错过这一步

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane: $ move path-to-download/google-services.json app/

复制谷歌服务。你刚刚下载到你的Android Studio项目的app/或移动/目录中的json文件。打开Android Studio终端窗格:$ move path to-download/google-services。json app /

Have fun.

玩得开心。

#14


0  

You need to check the current version as in the link below says, by now:

你需要检查当前的版本,如下面的链接所示,现在:

classpath 'com.google.gms:google-services:1.3.0-beta4'

Check this answer:

检查这个答案:

Update gradle version

gradle更新版本

#15


0  

We have to look for the last version in my case was:

我们必须在我的案例中寻找最后一个版本:

dependencies {    
    classpath 'com.google.gms:google-services:1.4.0-beta3'
}

Here you can find a list of the versions.

在这里您可以找到一个版本的列表。

#16


0  

I got a similar problem while following the instructions for implementing a GCM client in Android Studio, however, the message I got was :

我在Android Studio中实现GCM客户端时遇到了类似的问题,但是我得到的信息是:

Error: Could not find com.google.gms:google-services:1.3.0-beta1...

错误:无法找到com.google.gms:google-services:1.3.0-beta1…

Although I never figured out what was wrong, I simply copied my sources, resources, manifest, and keystore into a new Android Studio project. I then edited the auto-generated gradle build files for the new project by manually re-adding my dependencies.

虽然我从来没有想过什么是错的,但我只是简单地将我的资源、资源、清单和密钥库复制到一个新的Android Studio项目中。然后,我通过手工重新添加依赖项来编辑为新项目自动生成的渐变构建文件。

I made sure not to copy over my build files from the old project verbatim (since the source of the error likely lay in them somewhere).

我确保不会将我的构建文件逐字复制到旧的项目中(因为错误的来源很可能是它们中的某个地方)。

It is not a satisfying solution, but it worked for me and it took little time.

这不是一个令人满意的解决方案,但它对我起了作用,而且花费的时间也很少。

#17


0  

For me adding this under dependencies worked

对我来说,在依赖项下添加这个是可行的

compile 'com.google.gms:google-services:3.0.0'

#18


0  

Inside the .idea folder exists a workspace.xml file that defines the project's structure. I suggest you to close Android Studio, then delete .idea folder and then import the project again. The .idea would be generated by the IDE again. For me this solution works.

在.idea文件夹中存在一个工作区。定义项目结构的xml文件。我建议您关闭Android Studio,然后删除.idea文件夹,然后再次导入项目。.idea将再次由IDE生成。对我来说,这个解决方案是有效的。

#19


0  

You should just add classpath 'com.google.gms:google-services:1.3.0-beta1' to dependencies of your (Top level build file) the build.gradle that has the (Project:<name of your project). Hope this helps!

您只需将类路径'com.google.gms:google-services:1.3.0-beta1'添加到构建的依赖项(*构建文件)中。具有(项目: <项目名称)的级别。希望这可以帮助!< p>

#20


0  

I recently updated to Android Studio 2.3 and somehow apply plugin doesn't work.

我最近更新了Android Studio 2.3,不知何故应用插件不能工作。

After that, I tried various ways and then what work is when I commented out app's build.gradle:

在那之后,我尝试了各种方法,当我注释掉app的build时,我的工作是什么。

apply plugin: 'com.google.gms.google-services'

and then I add this to top-level build.gradle (below classpath 'com.android.tools.build:gradle:2.2.3'):

然后我将它添加到*构建中。gradle(下图类路径com.android.tools.build:gradle:2.2.3):

classpath 'com.google.gms:google-services:3.0.0'

and then it works.

然后它的工作原理。

#1


73  

I ran into the same issue today. In the samples they use this line instead: classpath 'com.google.gms:google-services:1.3.0-beta1' This works.

我今天遇到了同样的问题。在这些示例中,他们使用了这一行:classpath的com.google.gms:google-services:1.3.0-beta1“这行得通。

#2


50  

For me I had to switch the repository to jcenter(). I was using mavenCentral and getting this error. As soon as I switched to jcenter() it pulled the dependency down.

对于我来说,我必须将存储库切换到jcenter()。我使用mavenCentral得到这个错误。当我切换到jcenter()时,它将依赖项拉下。

To do this, open your build.gradle and replace each instance of mavenCentral() with jcenter()

为此,打开您的构建。将mavenCentral()的每个实例替换为jcenter()

#3


13  

Google updated their guide. Where it was classpath 'com.google.gms:google-services:1.0' now reads classpath 'com.google.gms:google-services:1.3.0-beta1' like joluet suggested.

谷歌更新他们的指南。google. google.gms:google-services:1.0' now read classpath 'com.google.gms:google-services:1.3.0-beta1', joluet建议的。

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

#4


10  

Google now released the plugin v1.3.0

谷歌现在发布了插件v1.3.0

I was able to solve it using this:

我可以用这个解出来

classpath 'com.google.gms:google-services:1.3.0'

类路径的1.3.0 com.google.gms:谷歌服务:版本

#5


10  

I resolved this issue by doing the following things:

我通过以下几点来解决这个问题:

  1. In build.gradle (at project level):

    在构建。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()
        }
    }
    
  2. In build.gradle (at module level):

    在构建。gradle(在模块级):

    On top added:

    上面说:

    apply plugin: 'com.google.gms.google-services'
    

    and in dependecies added:

    而在dependecies补充道:

    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    

Apart from this make sure you have updated the Google Play services and Google repository in the SDK.

除此之外,请确保您已经在SDK中更新了谷歌Play服务和谷歌存储库。

#6


7  

As of 25th Nov,2015, google released a newer version.

截至2015年11月25日,谷歌发布了一个新版本。

Try adding: classpath 'com.google.gms:google-services:2.0.0-alpha1'

尝试添加:类路径com.google.gms:谷歌服务:2.0.0-alpha1”

And don't forget to add jcenter() repository under buildscript.

不要忘记在buildscript中添加jcenter()存储库。

Thanks.

谢谢。

#7


4  

I think you forgotten gradle's project level,

我想你忘了葛莱蒂的项目水平,

From developers page:

从页面开发人员:

Add the dependency to your project-level build.gradle
classpath 'com.google.gms:google-services:1.5.0-beta2'

将依赖项添加到项目级别的构建中。gradle类路径的com.google.gms:谷歌服务:1.5.0-beta2

Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'

将插件添加到应用程序级别的构建中。gradle:应用插件:“com.google.gms.google-services”

#8


4  

Google has updated GCM go check it and for that you have to update your Android Studio too.

谷歌已经更新了GCM go check它,为此你也必须更新你的Android Studio。

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

#9


3  

I would advise you against doing what you are doing. I did it too (by following Set up a GCM Client App on Android blindly) but ended up with exceeding 65K method limit.

我劝你不要做你正在做的事。我也这么做了(通过盲目地在Android上建立一个GCM客户端应用),但最终超过了65K的方法限制。

So, you should remove the following lines from your gradle:

所以,你应该从你的等级中删除以下几行:

apply plugin: 'com.google.gms.google-services'
classpath 'com.google.gms:google-services:1.0'

Now import APIs of Google Plus with simple gradle import:

现在导入谷歌的api加上简单的gradle导入:

compile 'com.google.android.gms:play-services-plus:8.1.0'

#10


3  

Adding jcenter repository to project level build.gradle helped in my case:

将jcenter存储库添加到项目级别的构建中。葛莱蒂帮了我的忙:

buildscript {
    repositories {
        jcenter();
        mavenCentral()
    }

#11


1  

I was trying to setup firebase for my android app when I faced this problem. Following screenshot should clarify things -

当我遇到这个问题时,我正在为我的android应用程序安装firebase。下面的截图应该澄清一些事情

错误:找不到com.google.gms:google-services:1.0。在build中添加谷歌服务插件时。gradle android工作室

Couple of things I would like to point out - 1. Once you

我想指出的几点是- 1。一旦你

apply plugin: 'com.google.gms.google-services'

This line should be at the bottom of the app level gradle file. Not sure why but putting at the top did not workout for me.

这一行应该在应用程序级文件的底部。我不知道为什么,但把它放在最上面对我来说并不合适。

#12


1  

If you use Android Studio, try to add google service with the IDE.

如果您使用Android Studio,请尝试在IDE中添加谷歌服务。

  1. Right click on folder module.
  2. 右键单击文件夹模块。
  3. On left list at Developer Services choose desired service.
  4. 在开发人员服务的左侧列表中选择所需的服务。
  5. Wait for syncing and the IDE will automatically add google dependecies.
  6. 等待同步,IDE将自动添加谷歌依赖项。
  7. add classpath on buildscript

    buildscript上添加类路径

    buildscript { repositories { jcenter() } dependencies { classpath 'com.google.gms:google-services:1.3.0-beta1' } }

    {jcenter()}依赖项{classpath 'com.google.gms:google-services:1.3.0-beta1'}}

#13


0  

You maybe miss this step

你可能会错过这一步

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane: $ move path-to-download/google-services.json app/

复制谷歌服务。你刚刚下载到你的Android Studio项目的app/或移动/目录中的json文件。打开Android Studio终端窗格:$ move path to-download/google-services。json app /

Have fun.

玩得开心。

#14


0  

You need to check the current version as in the link below says, by now:

你需要检查当前的版本,如下面的链接所示,现在:

classpath 'com.google.gms:google-services:1.3.0-beta4'

Check this answer:

检查这个答案:

Update gradle version

gradle更新版本

#15


0  

We have to look for the last version in my case was:

我们必须在我的案例中寻找最后一个版本:

dependencies {    
    classpath 'com.google.gms:google-services:1.4.0-beta3'
}

Here you can find a list of the versions.

在这里您可以找到一个版本的列表。

#16


0  

I got a similar problem while following the instructions for implementing a GCM client in Android Studio, however, the message I got was :

我在Android Studio中实现GCM客户端时遇到了类似的问题,但是我得到的信息是:

Error: Could not find com.google.gms:google-services:1.3.0-beta1...

错误:无法找到com.google.gms:google-services:1.3.0-beta1…

Although I never figured out what was wrong, I simply copied my sources, resources, manifest, and keystore into a new Android Studio project. I then edited the auto-generated gradle build files for the new project by manually re-adding my dependencies.

虽然我从来没有想过什么是错的,但我只是简单地将我的资源、资源、清单和密钥库复制到一个新的Android Studio项目中。然后,我通过手工重新添加依赖项来编辑为新项目自动生成的渐变构建文件。

I made sure not to copy over my build files from the old project verbatim (since the source of the error likely lay in them somewhere).

我确保不会将我的构建文件逐字复制到旧的项目中(因为错误的来源很可能是它们中的某个地方)。

It is not a satisfying solution, but it worked for me and it took little time.

这不是一个令人满意的解决方案,但它对我起了作用,而且花费的时间也很少。

#17


0  

For me adding this under dependencies worked

对我来说,在依赖项下添加这个是可行的

compile 'com.google.gms:google-services:3.0.0'

#18


0  

Inside the .idea folder exists a workspace.xml file that defines the project's structure. I suggest you to close Android Studio, then delete .idea folder and then import the project again. The .idea would be generated by the IDE again. For me this solution works.

在.idea文件夹中存在一个工作区。定义项目结构的xml文件。我建议您关闭Android Studio,然后删除.idea文件夹,然后再次导入项目。.idea将再次由IDE生成。对我来说,这个解决方案是有效的。

#19


0  

You should just add classpath 'com.google.gms:google-services:1.3.0-beta1' to dependencies of your (Top level build file) the build.gradle that has the (Project:<name of your project). Hope this helps!

您只需将类路径'com.google.gms:google-services:1.3.0-beta1'添加到构建的依赖项(*构建文件)中。具有(项目: <项目名称)的级别。希望这可以帮助!< p>

#20


0  

I recently updated to Android Studio 2.3 and somehow apply plugin doesn't work.

我最近更新了Android Studio 2.3,不知何故应用插件不能工作。

After that, I tried various ways and then what work is when I commented out app's build.gradle:

在那之后,我尝试了各种方法,当我注释掉app的build时,我的工作是什么。

apply plugin: 'com.google.gms.google-services'

and then I add this to top-level build.gradle (below classpath 'com.android.tools.build:gradle:2.2.3'):

然后我将它添加到*构建中。gradle(下图类路径com.android.tools.build:gradle:2.2.3):

classpath 'com.google.gms:google-services:3.0.0'

and then it works.

然后它的工作原理。