Android Studio - 没有添加依赖项的选项?

时间:2017-02-16 19:40:25

标签: java android google-maps android-studio gradle

我想将GooglePlayServices添加到现有项目(Libgdx)中。但我有一个问题,在我将它们添加到build.gradle文件后,它们不会显示出来。我已经使用SDK管理器安装了GooglePlayServices。我做错了什么..?

当我转到依赖项选项卡下的项目结构时,只有3个不同的选项:

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

  2. 添加资料库

  3. 添加模块依赖项(当我点击此项时,我可以将我的主模块或核心模块添加为依赖项。没有其他选项)

  4. 下面是我的项目树的照片:

    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"
    }
    

    感谢您的帮助和时间!

1 个答案:

答案 0 :(得分:0)

我找到了iusse!

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