无法构建 Tango c 示例

Can't build Tango c examples

我下载了 Tango C examples 并在 Android Studio 中打开了 point-cloud-jni-example。我已经安装了 ndk 并将 ndk.dir=E:\Android\sdk\ndk-bundle 添加到我的 local.properties 文件中。 Gradle 同步没有错误,但是当我 运行 时,我得到这个错误:

Error:Execution failed for task ':app:ndkBuild'. A problem occurred starting process 'command 'E:\Android\sdk\ndk-bundle/ndk-build''

我在 motion-tracking-jni-example 和 hello-tango-jni-example 中遇到了同样的错误,我假设其他人也是如此。

我做错了什么?

build.gradle(应用):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.projecttango.experiments.nativepointcloud"
        minSdkVersion 19
        targetSdkVersion 19
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = [];
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn ndkBuild
}

task ndkBuild(type: Exec) {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"
    commandLine ndkbuild, '-C', file('src/main/jni').absolutePath
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

build.gradle(项目):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.1.0'
        }
    }

allprojects {
    repositories {
        jcenter()
    }
}

我的系统:

Windows 8.1 64 bit
Android Studio 1.3 (AI-141.2117773)
NDK r10e extracted to E:\Android\sdk\ndk-bundle
Device: Project Tango Tablet with Schur core

您需要将“.cmd”附加到 ndkbuild 命令。也就是说,我的意思是行

def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"

应该阅读

def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build.cmd"

这不是你自己的错,我在 Surface 上编译时发现了同样的问题。