Android Wear的libGDX启动器?

Android Wear的libGDX启动器?,android,libgdx,wear-os,watch,launcher,Android,Libgdx,Wear Os,Watch,Launcher,如何在Android Wear上获得libGDX游戏? 我用gdx-setup.jar创建了一个示例项目,但这只创建了一个android启动器 我补充说 <uses-feature android:name="android.hardware.type.watch" /> 来建造格拉德尔 但Android Studio只创建了一个Android应用程序 如何在Android Wear上启动libGDX游戏?示例android launcher不适用于我。使用gdx-setup.ja

如何在Android Wear上获得libGDX游戏? 我用gdx-setup.jar创建了一个示例项目,但这只创建了一个android启动器

我补充说

<uses-feature android:name="android.hardware.type.watch" />
来建造格拉德尔

但Android Studio只创建了一个Android应用程序


如何在Android Wear上启动libGDX游戏?示例android launcher不适用于我。

使用gdx-setup.jar创建项目,然后使用空白的wear应用程序创建一个新的wear模块,并为wear模块尝试以下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"
            }
        }
    }
}
apply插件:“com.android.application”
安卓{
编译DK22版
buildToolsVersion“22.0.1”
默认配置{
applicationId“com.example.wear”
明斯克版本21
targetSdkVersion 22
版本代码1
版本名称“1.0”
}
建筑类型{
释放{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard rules.pro'
}
}
配置{本地人}
}
依赖关系{
编译项目(“:core”)
编译文件树(目录:“libs”,包括:['*.jar'])
编译文件树(目录:“../libs”,包括:“*.jar”)
编译'com.google.android.support:wearable:1.1.0'
编译'com.google.android.gms:play services wearable:7.5.0'
编译“com.badlogicgames.gdx:gdx后端android:$gdxVersion”
本地人“com.badlogicgames.gdx:gdx平台:$gdxVersion:natives armeabi”
natives“com.badlogicgames.gdx:gdx平台:$gdxVersion:natives-armeabi-v7a”
natives“com.badlogicgames.gdx:gdx平台:$gdxVersion:natives-x86”
}
//在CLI上编译时需要将JNI共享库添加到APK
tasks.withType(com.android.build.gradle.tasks.PackageApplication){pkgTask->
pkgTask.jniFolders=new HashSet()
pkgTask.jniFolders.add(新文件(projectDir,'libs'))
}
//每次执行gradle时调用,获取
//本地配置,并将它们提取到适当的libs/文件夹中
//所以他们被APK包围了。
任务copyAndroidNatives(){
文件(“libs/armeabi/”).mkdirs();
文件(“libs/armeabi-v7a/”).mkdirs();
文件(“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){
抄袭{
来自zipTree(罐子)
输入输出目录
包括“*.so”
}
}
}
}

我认为您不需要依赖项部分。阅读不,不要工作。我已经尝试了很多方法,但它只是一个针对Android的apk,而不是针对Android Wear。即使我添加了Android War模块并复制了启动程序代码,它也无法启动libgdx游戏核心类
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"
            }
        }
    }
}