【发布时间】:2017-07-06 02:35:34
【问题描述】:
我想将 GooglePlayServices 添加到已经存在的项目 (Libgdx) 中。但是我有一个问题,在我将它们添加到 build.gradle 文件后,它们没有出现。我已经使用 SDK 管理器安装了 GooglePlayServices。我做错了什么..?
当我转到依赖项选项卡下的项目结构时,只有 3 个不同的选项:
添加 Jar 或文件夹(自行解释)
添加库
添加模块依赖项(当我单击此按钮时,我能够将我的主模块或核心模块添加为依赖项。没有其他选项)
这是我的项目树的图片:
这是我的项目结构的图片:
我可以导入的唯一依赖项是模块一……这很奇怪。
这是我的整个 build.gradle(我发布所有内容,因为我完全不知道错误部分在哪里)我标记了我为 GooglePlayService 添加的行:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "ParallelOrigin"
gdxVersion = '1.9.5'
roboVMVersion = '2.3.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":android") {
apply plugin: "android"
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:$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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
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.badlogicgames.ashley:ashley:$ashleyVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-android:1.2.0"
//----------------------------------------------------------------------------//
//--------------------------Added by myself-----------------------------------//
//----------------------------------------------------------------------------//
compile "com.android.support:support-core-utils:23.2.1"
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.android.gms:play-services:10.0.1'
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
compile "com.underwaterapps.overlap2druntime:overlap2d-runtime-libgdx:0.1.0"
compile "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
compile "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
compile "de.tomgrill.gdxdialogs:gdx-dialogs-core:1.2.0"
//----------------------------------------------------------------------------//
//--------------------------Added by myself-----------------------------------//
//----------------------------------------------------------------------------//
compile "com.android.support:support-core-utils:23.2.1"
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.android.gms:play-services:10.0.1'
}
}
tasks.eclipse.doLast {
delete ".project"
}
感谢您的帮助和时间!
【问题讨论】:
-
好像你已经添加了,再试试同步你的项目吗?
-
@king 已经这样做了,我也重新启动了我的电脑。但是那些 GooglePlayService 依赖项没有出现。没有出现依赖项,只有我的 2 个文件夹(android 和核心)...我通过 libgdx 生成器创建了这个项目。有点奇怪,我比较了 Android Studio 制作的项目和 libgdx 一个。 android studio 有很多其他选择。在那里我也可以添加依赖项而无需任何 iusses。
-
有点傻,但尝试从文件菜单中使现金无效
-
@MCZ 感谢您的回答!我要试试。但奇怪的是,有在原生 Android Studio 应用程序上添加依赖项的选项。还有其他一些选择..
-
@MCZ 这些选项在 libgdx 导入中不可用。
标签: java android google-maps android-studio gradle