3

I'm trying out the Oculus Mobile SDK V1.0.4, following the instructions at Android Studio Basics.

I imported the build.gradle file for VrCubeWorld_Framework and when switching to the Project view, all dependencies are shown in bold, including VrAppFramework.

When I try to build it though, I don't get very far. The first error I get is:

error: package com.oculus.vrappframework does not exist

in vrcubeworld\MainActivity.java.

It seems pretty obvious what's going on, it doesn't know about the activity in the framework, but how do I make that connection? Do I need to add it as an external library / project or something? Since it's already bold, I thought that would have been taken care of.

For reference, here is the build.gradle:

apply plugin: 'com.android.application'
apply from: "${rootProject.projectDir}/VrApp.gradle"

dependencies {
  compile project(':VrAppFramework:Projects:AndroidPrebuilt')
  compile project(':VrAppSupport:VrGUI:Projects:AndroidPrebuilt')
  compile project(':VrAppSupport:VrLocale:Projects:AndroidPrebuilt')
  compile project(':VrAppSupport:VrSound:Projects:AndroidPrebuilt')
}

android {
  project.archivesBaseName = "vrcubeworldfw"

  defaultConfig {
    applicationId "com.oculus.vrcubeworldfw"
  }

  compileSdkVersion 19
  buildToolsVersion '23.0.1'

  buildTypes {
    debug {
      jniDebuggable true
    }
  }

  sourceSets {
    main {
      manifest.srcFile 'AndroidManifest.xml'
      java.srcDirs = ['../../java']
      jniLibs.srcDir 'libs'
      res.srcDirs = ['../../res']
      assets.srcDirs = ['../../assets']
    }
  }
}
Curyous
  • 8,716
  • 15
  • 58
  • 83

1 Answers1

2

This sums up the exact cause of the error Oculus Forums. However, after some digging it gets the build type from the task name.

Don't call:

gradle build

call:

gradle assembleDebug

EDIT FOR ANDROID STUDIO:

I'm working out of a non-vanilla oculus vr project so some of my changes may not apply. However, I found that the issue with android studio is that it passes in the full path of the task to gradle for building. And inside the build.gradle file it checks to see if the whole task name is "assembleDebug"

Relevant Source in build.gradle:

  if ( project.file("build.gradle").exists() ) {
    project.gradle.startParameter.taskNames.each { taskName -> 
        if ( taskName == "assembleDebug" || taskName == "assembleRelease" || taskName == "clean" ) {
          if ( project.hasProperty( "buildType" ) ) {
            //throw new GradleException( "cannot configure multiple build tasks" )
          }
          project.ext.buildType = taskName - "assemble"
       }
    }
  }

Changing it to check if the task contains release or debug helped me alot:

  if ( project.file("build.gradle").exists() ) {
    project.gradle.startParameter.taskNames.each { taskName -> 
        if (taskName.contains( "Debug" ) ) {
          project.ext.buildType = "Debug";
        } else if( taskName.contains( "Release" ) ) {
          project.ext.buildType = "Release";
        }    
    }
  }
texel
  • 184
  • 9
  • Thanks, I can build it this way using the command line. Is there any way to get it to work with Android Studio? After the build and a Gradle sync, the IDE still doesn't recognise com.oculus.vrappframework.VrActivity – Curyous Feb 18 '17 at 06:50
  • Added some more info to the answer, if you have more issues give me some more details about your specific problem as I'm not using vanilla oculus vr so my problems might be different than yours. – texel Feb 19 '17 at 16:15
  • Holy heck! That's amazing! It worked! Even though the fix is simple. I am very grateful as I was stumped. @texel can I repay you by buying you a book from Amazon or something? – Curyous Feb 21 '17 at 06:57
  • No worries, just look me up if you're ever in Dallas. – texel Feb 22 '17 at 14:44