2017-02-16 152 views
1

我想将GooglePlayServices添加到已有的项目(Libgdx)中。但是我有一个问题,在将它们添加到build.gradle文件后,它们不显示出来。我已经使用SDK管理器安装了GooglePlayServices。我做错了什么 ..?Android Studio - 无法添加依赖关系?

当我去项目结构的依赖性选项卡下,也只有3个不同的选项:

  1. 添加JAR或文件夹(selfexplained)

  2. 添加库

  3. 添加模块依赖(当我点击这个,我能够添加我的主或核心模块作为依赖项。没有其他选项)

我的继承人项目树的图片:

ProjectTree

我的继承人项目结构的图片:

Project Structure

唯一Dependencie我可以导入是一个模块...真奇怪。

ModuleDependencie

而且继承人什么我的整个的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" 
} 

感谢您的帮助和时间!

+0

看起来像你已经添加它,尝试再次同步你的项目? – king

+0

@king已经这样做了,我也重新启动了我的电脑。但那些GooglePlayService依赖关系不显示。没有依赖关系出现,只有我的2 foldern(Android和核心)...我通过libgdx生成器创建了这个项目。它有点奇怪,我比较了Android Studio项目和libgdx项目。 Android工作室有很多其他选择。在那里,我也可以添加依赖没有任何iusses。 – genaray

+0

一种愚蠢的,但尝试使文件菜单中的钱币无效 –

回答

0

我找到了iusse!

这只发生,因为我的项目不是一个gradle。我只需要迁移它,然后我可以导入这些Maven依赖项!