Jim
Jim

Reputation: 1

Error with building Google VR SDK sample code

I'm a newbie for developing android program and I'm struggling to get the sample code "ndk-treasurehunt" running. I followed the instructions to build the project and ran into many errors. After modified the build.gradle file, I was able to make a few progress but right now I'm still stuck with the following error.


Build command failed. Error while executing process C:\Users\xxx\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\xxx\ProgrammingAndroid\gvr-android-sdk-1.150.0\samples\ndk-treasurehunt.externalNativeBuild\cmake\debug\x86 --target treasurehunt_jni} ninja: error: '../../../../libraries/jni/x86/libgvr.so', needed by '../../../../build/intermediates/cmake/debug/obj/x86/libtreasurehunt_jni.so', missing and no known rule to make it.


The build.gradle I modified is like this:


apply plugin: 'com.android.application'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    allprojects {
        repositories {
            jcenter()
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}



android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.google.vr.ndk.samples.controllerpaint"
        minSdkVersion 25
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        externalNativeBuild {
            cmake {
                cppFlags "-std=gnu++11"
                arguments "-DGVR_LIBPATH=${project.rootDir}/libraries/jni",
                        "-DGVR_INCLUDE=${project.rootDir}/libraries/headers"
            }
        }
        buildTypes {
            release {
                minifyEnabled = true
                proguardFiles.add(file("${project.rootDir}/proguard-gvr.txt"))
            }
        }
        ndk {
            // This sample builds all architectures by default. Note that if you
            // only want to build for a specific architecture, you need to
            // remove the appropriate lines below. You also need to remove the
            // .so files from the apk using
            // "packagingOptions {exclude('lib/armeabi-v7a/*')}" in the android
            // section.
            abiFilters "arm64-v8a"
            abiFilters "armeabi-v7a"
            abiFilters "x86"
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
}


dependencies {
    implementation 'com.google.vr:sdk-audio:1.150.0'
    implementation 'com.google.vr:sdk-base:1.150.0'
}

build.dependsOn(':extractNdk')

Please help! Thank you!

Upvotes: 0

Views: 735

Answers (1)

VirtuallyEverything
VirtuallyEverything

Reputation: 1

Please ensure that your NDK is installed and extracted correctly by performing the following:

  1. Add the NDK to Android Studio via: Tools -> SDK Manager -> SDK Tools -> NDK
  2. Open Android Studio Terminal at the bottom of IDE or through View -> Tool Windows -> Terminal
  3. Run the following command in the terminal gradelw :extractNdk
  4. In the settings.gradle, uncomment the following line include ':sample:ndk-treasurehunt' which has since been replaced by include ':samples:ndk-hellovr' if you are using a newer NDK

Upvotes: 0

Related Questions