我是开发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')
请帮忙!谢谢!
答案 0 :(得分:0)
请执行以下操作,以确保正确安装并解压缩了您的NDK:
Tools -> SDK Manager -> SDK Tools -> NDK
View -> Tool Windows -> Terminal
gradelw :extractNdk
中运行以下命令include ':sample:ndk-treasurehunt'
,如果您使用的是较新的NDK,则该行已被include ':samples:ndk-hellovr'
取代