构建Google VR SDK示例代码时出错

时间:2018-06-19 03:11:22

标签: android cmake google-vr google-vr-sdk

我是开发Android程序的新手,我正在努力获取示例代码" ndk-treasurehunt"运行。我按照说明构建项目并遇到了许多错误。修改build.gradle文件后,我能够取得一些进展,但是现在我仍然遇到以下错误。

构建命令失败。 执行进程C:\ Users \ xxx \ AppData \ Local \ Android \ Sdk \ cmake \ 3.6.4111459 \ bin \ cmake.exe时出错,参数为{--build C:\ Users \ xxx \ ProgrammingAndroid \ gvr-android-sdk -1.150.0 \ samples \ ndk-treasurehunt.externalNativeBuild \ cmake \ debug \ x86 --target treasurehunt_jni} 忍者:错误:' ../../../../ libraries / jni / x86 / libgvr.so',需要' ../../../ .. /build/intermediates/cmake/debug/obj/x86/libtreasurehunt_jni.so' ;,遗失并且没有已知的规则来制作它。

我修改的build.gradle是这样的:

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')

请帮忙!谢谢!

1 个答案:

答案 0 :(得分:0)

请执行以下操作,以确保正确安装并解压缩了您的NDK:

  1. 通过以下方式将NDK添加到Android Studio:Tools -> SDK Manager -> SDK Tools -> NDK
  2. 打开IDE底部的Android Studio终端,或通过View -> Tool Windows -> Terminal
  3. 在终端gradelw :extractNdk中运行以下命令
  4. 在settings.gradle中,取消注释以下行include ':sample:ndk-treasurehunt',如果您使用的是较新的NDK,则该行已被include ':samples:ndk-hellovr'取代