2017-02-16 279 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依賴項!

相關問題