0

我是开发 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')

请帮忙!谢谢!

4

1 回答 1

0

请通过执行以下操作确保您的 NDK 已正确安装和提取:

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