Search code examples
androidandroid-ndkgoogle-project-tango

Can't build Tango c examples


I downloading the Tango C examples and opened point-cloud-jni-example in Android Studio. I have ndk installed and added ndk.dir=E:\Android\sdk\ndk-bundle to my local.properties file. Gradle syncs without errors, but when I run, I get this error:

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

I get the same error with motion-tracking-jni-example and hello-tango-jni-example and I assume the others as well.

What am I doing wrong?

build.gradle (app):

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 (Project):

// 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()
    }
}

My system:

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

Solution

  • You need to append '.cmd' to the ndkbuild command. By that, I mean that the line

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

    should read

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

    It was no fault of your own, I noticed the same issue when I went to compile on my Surface.