2016-08-10 9 views
2

私のプロジェクト、Gear VRFにライブラリを追加しました。ライブラリのbuild.gradleファイルはOculus sdkを見つけることができません。私はエラー "Oculusファイルをコピーしない:OVR_MOBILE_SDKが見つからない、"ハードコードされたパスと環境変数に頼っている。 OVR_MOBILE_SDKが見つかりません。 Gradleログの一番下には「タスクフレームワークの実行に失敗しました:buildNative User /../../ Android/sdk/ndk-bundle/ndk-buildが0以外の終了値2で終了しました。 これに関する助け問題が高く評価され、私は以下のライブラリのbuild.gradleのコードを入れているおかげAndroid StudioがOculus SDKを見つけることができません

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(); 
} 

答えて

1

がgradle.propertiesファイルを見つけ、次の行を追加します。。

# Un-comment and add the path to ovr directory 
OVR_MOBILE_SDK=\.\.\/GearVRf\/ovr_mobile_sdk 
関連する問題