无法解析符号“GooglePlayServicesClient”

7

我正在尝试将一个项目从Eclipse迁移到Android Studio。该项目可以在Eclipse中构建,并已成功导入Android Studio,但是我在Android Studio中遇到了 Cannot resolve symbol 'GooglePlayServicesClient' 错误。

我按照官方教程在Android Studio中导入了Google Play服务以及另一个在我的项目中使用的包 "com.google.android.gms.common.ConnectionResult",但只有 'GooglePlayServicesClient' 无法被解析。

issue

我还尝试过清除并重新构建项目,但问题仍然存在。我做错了什么?

更新:

我的 build.gradle 文件:

...
dependencies {
    compile project(':libraryListViewAnimations')
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/commons-net-3.1-sources.jar')
    compile files('libs/commons-net-3.1.jar')
    compile files('libs/mail.jar')
}

你有查看过你的 .classpath /.iml 文件吗?你能看到这个依赖关系吗?你尝试在 IDE 中刷新依赖吗?它发生在哪个范围内?(主要/main,测试/test还是运行时/runtime) - CyberAleks
将我的模块 build.gradle 的依赖项复制到项目 build.gradle 后,我遇到了“Gradle DSL 方法未找到:compile()”的错误。 - TRX
观看这个视频。https://www.youtube.com/watch?v=2q7XGuH2Q-s 或许能有所帮助。 - CyberAleks
@fabricator 我比他早问了... :/ - TRX
显示剩余2条评论
2个回答

11

GooglePlayServicesClient已经过时,不再包括在Google Play Services 7.x库中。Google建议使用GoogleApiClient代替。

请参阅Android开发人员文档中的访问Google API

"注意:如果您有一个使用GooglePlayServicesClient子类连接到Google Play服务的现有应用程序,则应尽快迁移到GoogleApiClient。"


0
你在build.gradle里面添加了compile 'com.google.android.gms:play-services:7.0.0'吗? 你可以在这里找到更多指导here。希望能帮到你。

是的,我在我的 build.gradle 文件中有这行代码。 - TRX
我不确定为什么,但我看到它重复了两行编译。你应该选择最新版本的'com.google.android.gms:play-services:+' 编译'com.google.android.gms:play-services:7.0.0' - MichaelP
我刚刚检查了com.google.android.gms.common并看到了GooglePlayServicesClient类。我不确定为什么你没有看到它。只需获取最新版本并再次同步构建gradle即可。 - MichaelP
1
你对此有任何结果吗? - Mathieu de Brito

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接