gpt4 book ai didi

Android Studio 无法找到 Oculus SDK

转载 作者:行者123 更新时间:2023-11-29 01:17:05 26 4
gpt4 key购买 nike

我刚刚向我的项目 Gear VRF 添加了一个库,但该库的 build.gradle 文件找不到 Oculus SDK。我收到错误“不复制 Oculus 文件:未找到 OVR_MOBILE_SDK,以及”依赖于硬编码路径和环境变量;未找到 OVR_MOBILE_SDK。在 Gradle 日志的底部,我还看到“任务框架执行失败:buildNative。用户/../../Android/sdk/ndk-bundle/ndk-build 已完成,退出值非零 2。在此问题上的任何帮助表示赞赏,我已将库的 build.gradle 代码放在下面。谢谢。

    import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion '23.0.3'

defaultConfig {
minSdkVersion 19
targetSdkVersion 19

ndk {
moduleName "gvrf"
}
}

task copyOculusFiles(type: Copy) {
println "copying oculus binaries"
if (rootProject.hasProperty("OVR_MOBILE_SDK")) {
def oculusDir = rootProject.property("OVR_MOBILE_SDK")
copy {
from oculusDir+'/VrApi/Libs/Android/VrApi.jar'
into 'src/main/libs'
}
copy {
from oculusDir+'/VrApi/Libs/Android/armeabi-v7a/libvrapi.so'
into 'src/main/libs/armeabi-v7a'
}
copy {
from oculusDir+'/VrAppSupport/SystemUtils/Libs/Android/SystemUtils.jar'
into 'src/main/libs'
}
} else {
println "WARNING: not copying Oculus files; OVR_MOBILE_SDK not found"
}
}

task buildNative(type: Exec) {
if (rootProject.hasProperty("OVR_MOBILE_SDK")) {
environment 'OVR_MOBILE_SDK', rootProject.property("OVR_MOBILE_SDK")
} else {
println "WARNING: relying on hard-coded paths and environment variables; OVR_MOBILE_SDK not found"
}

def ndkbuild = ""
if (rootProject.hasProperty("ANDROID_NDK_HOME")) {
ndkbuild = rootProject.property("ANDROID_NDK_HOME")
ndkbuild += '/'
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkbuild += 'ndk-build.cmd'
} else {
ndkbuild += 'ndk-build'
}

if (rootProject.hasProperty("OVR_MOBILE_SDK")) {
environment 'OVR_MOBILE_SDK', rootProject.property("OVR_MOBILE_SDK")
}

commandLine '/Users/edhillon3/Library/Android/sdk/ndk-bundle/ndk-build', '-C', file('src/main').absolutePath, '-j', 16//, 'NDK_DEBUG=1'
}

buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
releaseToGitHub {
}
}

sourceSets.main {
java.srcDirs = ['src/main/java', 'src/main/backends/oculus']
jni.srcDirs = [] // no auto generation of Android.mk
// pre-compiled libraries
jniLibs {
srcDir 'src/main/libs'
}
}

task cleanNative(type: Exec) {
def ndkbuild = ""
if (rootProject.hasProperty("ANDROID_NDK_HOME")) {
ndkbuild = rootProject.property("ANDROID_NDK_HOME")
ndkbuild += '/'
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
ndkbuild += 'ndk-build.cmd'
} else {
ndkbuild += 'ndk-build'
}

if (rootProject.hasProperty("OVR_MOBILE_SDK")) {
environment 'OVR_MOBILE_SDK', rootProject.property("OVR_MOBILE_SDK")
}
commandLine '/Users/edhillon3/Library/Android/sdk/ndk-bundle/ndk-build', '-C', file('src/main').absolutePath, '-j', 16, 'clean'
}

clean.dependsOn 'cleanNative'

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn buildNative, copyOculusFiles
}

task eclipseZip(type: Zip) {
into('GearVRf/res/') {
from 'src/main/res/'
}
into('GearVRf/libs/') {
from('src/main/libs/') {
exclude 'libassimp.so'
exclude 'libjnlua.so'
}
from('build/intermediates/bundles/release/') {
include 'classes.jar'
rename('classes.jar', 'gvrf.jar')
}
}
into('GearVRf/') {
from('src/main/') {
include 'AndroidManifest.xml'
include '.project'
include '.classpath'
include 'project.properties'
}
}
into('GearVRf/java') {
from('src/main/') {
include 'donotdelete.txt'
}
}

baseName 'gvrf-for-eclipse'
}

task eclipseAssembleReleaseToGitHub() << {
println "preparing android library project for eclipse"

eclipseZip.execute()

copy {
from 'build/distributions/gvrf-for-eclipse.zip'
into 'build/outputs/aar/'
}

project.delete('build/distributions/gvrf-for-eclipse.zip')
}

task uploadToGitHub(type: Exec) {
onlyIf {
System.env['RELEASE_ID'] != null
}
onlyIf {
System.env['ACCESS_TOKEN'] != null
}

commandLine '../../tools/upload_to_github', file('build/outputs/aar/framework-releaseToGitHub.aar').absolutePath
}
uploadToGitHub.doFirst {
println('uploading to github')
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
}

assembleDebug {}.doLast {
task copyAARFiles(type: Copy) {
if (rootProject.hasProperty("LIBS_DIRECTORY")) {
println "copying aar files to the libs_directory"
def libsdirPath = projectDir.absolutePath + '/../../../' +
rootProject.property("LIBS_DIRECTORY")
def libsDir = new File(libsdirPath);
if (libsDir.exists()) {
from 'build/outputs/aar'
into libsDir
include '**/*.aar'
} else {
println "Cannot copy aar files, libs directory does not exist!"
}
}
}

assembleReleaseToGitHub {}.doLast {
println 'removing oculus binaries'
exec {
commandLine = ['zip', '-d', 'build/outputs/aar/framework-releaseToGitHub.aar', 'libs/VrApi.jar']
}
exec {
commandLine = ['zip', '-d', 'build/outputs/aar/framework-releaseToGitHub.aar', 'libs/SystemUtils.jar']
}
exec {
commandLine = ['zip', '-d', 'build/outputs/aar/framework-releaseToGitHub.aar', 'jni/armeabi-v7a/libvrapi.so']
}

eclipseAssembleReleaseToGitHub.execute()
uploadToGitHub.execute();
}

最佳答案

找到 gradle.properties 文件并添加以下内容:

# Un-comment and add the path to ovr directory
OVR_MOBILE_SDK=\.\.\/GearVRf\/ovr_mobile_sdk

关于Android Studio 无法找到 Oculus SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38876692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com