【问题标题】:Facing serious issues in adding Google Play Services to my libgdx android project在将 Google Play 服务添加到我的 libgdx android 项目时面临严重问题
【发布时间】:2017-06-19 04:06:43
【问题描述】:
我对 android 游戏开发非常陌生,我想将 Google Play Services 库添加到我的项目中。我下载了 Google Play Services rev 25,将其复制到我的 sdk> extras> google 并将 google play services 库导入到我的项目中。我还通过选中该框将其复制到我的工作空间。我还通过进入导入项目的属性检查了库是否实际上是一个库。然后,我转到我的 android 项目 > 属性 > Android > 添加以添加 google play 服务库,但它不存在,项目选择窗口似乎已禁用。我多次清理、重启和重新安装 eclipse 和 google play 服务,但没有任何效果。
我附上了我的项目的一些图片。请给我建议,以便我可以继续我的第一个项目。Google Play Services Library Properties
My Android Project Properties
[我的 Android 项目清单][3][Google Play Services API 25 清单][4]
【问题讨论】:
标签:
java
android
eclipse
libgdx
【解决方案1】:
终于在与 eclipse 苦苦挣扎了将近一天后,我发现 eclipse 使用的是独立的 JRE,而不是 JRE 自带的 JDK。所以我将JDK添加到我的eclipse项目中,然后转到windows>preferences>gradle>arguments>并将工作区JRE设置为新添加的JDK。
我不知道这是否是真正的解决方案,但这样做之后我能够将 google play 服务添加到我的项目中。
希望对你有帮助。
【解决方案2】:
- 转到文件
{PROJECT_FOLDER}/build.gradle 并添加以下类路径:
buildscript {
....
dependencies{
....
classpath 'com.google.gms:google-services:3.0.0'
}
}
- 转到文件
{PROJECT_FOLDER}/android/build.gradle 并添加以下依赖项/插件:
dependencies {
...
compile 'com.google.android.gms:play-services-gcm:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
还记得在您的 SDK 管理器中安装 Google Repository。