通过gradle引用play-services对我来说停止了工作-归结起来-甚至我最初用作参考的样本也停止了工作: https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':auth'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':auth:compile'.
      > Could not find com.google.android.gms:play-services:3.1.36.
        Required by:
            gpsdemos:auth:unspecified

* 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: 3.577 secs

我担心只是版本增加了,但这提出了两个问题: #1)新的是什么? #2)为什么旧版本消失了?


当前回答

我错误地添加了compile com.google.android.gms:play-services:5。+在构建脚本块中的依赖项。您应该在第二个依赖项块中添加它。做改变->同步项目与gradle。

其他回答

只需从sdk管理器中安装谷歌存储库,然后重新启动Android Studio。

我也有同样的问题。

您应该在构建中添加一些依赖项。Gradle,就像这样

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libcocos2dx')
    compile 'com.google.firebase:firebase-ads:11.6.0'
// the key point line
    compile 'com.google.android.gms:play-services-auth:11.6.0'
}

在找到这篇文章之前,我已经在这个问题上挣扎了几个小时。就像@ligi说的,有些人有两个SDK文件夹(捆绑的Android Studio和Eclipse)。问题是,如果你在两个SDK文件夹上下载了谷歌Play Services库,你的ANDROID_HOME环境变量必须指向Android Studio使用的SDK文件夹。

SDK Folder A  (Used on Eclipse)
SDK Folder B  (Used on AS)

ANDROID_HOME=<path to SDK Folder B>

在改变这个变量的路径后,错误就消失了。

如果您已经安装了谷歌存储库,请确保更新了它。我必须更新我的谷歌存储库和服务。这是在我更新Android Studio之后。

除了安装存储库和SDK包之外,还应该注意版本号定期变化。此时,一个简单的解决方案是用加号(+)符号替换特定的版本号。

compile 'com.google.android.gms:play-services:+'

谷歌指令表明应该确保升级版本号,但是添加加号处理版本控制中的更改。还要注意,在Android Studio中构建时,当有新版本可用时,状态行中会出现一条消息。

你可以通过钻取正确的存储库路径来查看play服务的可用版本:

参考文献

该站点还提供了Eclipse和其他IDE的说明。