2015-05-04 38 views
2

如何在Android Wear上獲得我的libGDX遊戲? 我使用gdx-setup.jar創建了一個示例項目,但只創建一個android啓動器。適用於Android Wear的libGDX啓動器?

我加

<uses-feature android:name="android.hardware.type.watch" /> 

清單文件與此:

dependencies { 
    compile 'com.google.android.gms:play-services:[email protected]' 
    compile 'com.android.support:support-v4:20.0.+' 
    wearApp project(':wearable') 
} 

到的build.gradle。

但Android Studio只創建一個android應用程序。

如何在Android Wear上啓動我的libGDX遊戲?示例Android啓動程序不適用於我。

+0

我不認爲你需要依賴部分。閱讀[這裏](http://www.phoneprojects.com/blog/using-libgdx-on-android-wear/) – Fish

+0

不,不工作。我已經嘗試了很多方法,但它只是Android版的Android版本,不適用於Android Wear版本。即使添加Android War模塊並複製啓動程序代碼,也無法啓動libgdx遊戲核心類 – Goldk

回答

0

創建與GDX-setup.jar的項目,然後創建一個新的磨損模塊空白磨損應用程序並嘗試換着穿模塊下面的build.gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 22 
    buildToolsVersion "22.0.1" 

    defaultConfig { 
     applicationId "com.example.wear" 
     minSdkVersion 21 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    configurations { natives } 
} 

dependencies { 
    compile project(":core") 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile fileTree(dir: '../libs', include: '*.jar') 
    compile 'com.google.android.support:wearable:1.1.0' 
    compile 'com.google.android.gms:play-services-wearable:7.5.0' 
    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-x86" 
} 
// needed to add JNI shared libraries to APK when compiling on CLI 
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> 
    pkgTask.jniFolders = new HashSet<File>() 
    pkgTask.jniFolders.add(new File(projectDir, 'libs')) 
} 

// called every time gradle gets executed, takes the native dependencies of 
// the natives configuration, and extracts them to the proper libs/ folders 
// so they get packed with the APK. 
task copyAndroidNatives() { 
    file("libs/armeabi/").mkdirs(); 
    file("libs/armeabi-v7a/").mkdirs(); 
    file("libs/x86/").mkdirs(); 

    configurations.natives.files.each { jar -> 
     def outputDir = null 
     if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a") 
     if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi") 
     if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86") 
     if(outputDir != null) { 
      copy { 
       from zipTree(jar) 
       into outputDir 
       include "*.so" 
      } 
     } 
    } 
} 
相關問題