我正在尝试将Google Play服务添加到我的libGDX项目中,使用IntelliJ Idea进行开发。我已经按照这里的设置指南进行操作:https://developers.google.com/android/guides/setup
看起来很简单。我只是在对应部分的build.gradle文件中添加了那些代码行,所以现在的情况看起来像:
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services:11.2.0'
}
}
然后我尝试在Idea中同步我的gradle项目,结果出现了“无法解析”的错误。
好吧,设置指南也说“确保每次更新Google Play服务时更新此版本号”,但问题是似乎很难找到该版本号:根据Android SDK管理器,我的Google Play Services SDK版本为“43”,到目前为止,我一直无法将这种“11.2.0”或其他典型的版本字符串与“43”版本号相对应。而设置指南并没有提及这方面的内容。
总之,我尝试了许多与此相关的问题,但都没有成功。特别要指出的是,我已经正确更新了我的Android SDK,并且确定它正在被Idea使用(我已经三重检查过了...):
我正在使用API级别26,但无论如何,其他定义都在使用相同的Android SDK目录。此外,在这台笔记本电脑上我没有安装任何其他android SDK,因此不存在Idea使用其他SDK的问题。
欢迎任何想法。
apply plugin: 'com.google.gms.google-services'
。 - Tim