2015-05-04 39 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" 
      } 
     } 
    } 
} 
相关问题