Vuforia SDK and Android Studio?

Does anyone have access to how to get the latest Vuforia SDK (3.0.9) working in Android Studio?

All documentation provided is Eclipse oriented and out of date.

I tried to import the sample app, but that doesn't create, giving several "can't resolve symbol .." errors (I'm guessing because I haven't included the Vuforia library (since I don't know how).)

+3


source to share


1 answer


To compile Vuforia samples:

  • Import Vuforia samples [should be in VUFORIA_SDK/samples/VuforiaSamples-###

    . If there is only zip, then extract this]
  • The next step - handling how the folders were imported - is resolving the "cannot resolve symbol" errors. The problem is that the package name does not match the file path i.e. You need to move all files to base directoryapp/java

    • Note that this may not be necessary if Android Studio imported all folders correctly. Skip to step 3 if so.
    • Note that the project pane in Android Studio compresses all empty directories between them, which you can switch by clicking the gear icon in the Project pane and then unchecking the Compact empty middle packages checkbox
    • Currently, the files causing all the problems must be in app/java/samples/src/com...

      or somewhere very similar. The folder com

      must be moved to the root java folder, i.e.app/java

    • In the Project pane inside Android Studio, right-click the directory java

      and choose Show in Files. Navigate to the com

      currently folder as above and move it to app/java

      . Made for these mistakes!
  • Now you need to actually import the Vuforia jar dependency. This is in VUFORIA_SDK/build/java/vuforia

    , Vuforia.jar

    and needs to be moved to your project.
    • You can move this probably much more elegantly and into the correct folder, but I just personally dragged the file into the directory. Pay attention to this directory
  • Finally Android Studio should actually add this as a dependency
    • The easiest way to do this is to open a window called Project Structure with Ctrl + Alt + Shift + S or from the File menu at the top. Go to your application, then go to the Dependencies tab.
    • Click the plus button, then select 2. File Dependency
    • Go to the file Vuforia.jar

      you imported earlier and select
  • You have to include the file armeabi.jar

    as a dependency like in step 4

Side step: If you explicitly use the samples app, it still can't compile. Note that whoever wrote the application clearly tried to take advantage of the Eclipse sorting system and other Eclipse-based features. If Android Studio messes up the import of all files, you may need to do more for the application to actually collect. You may have an error (runtime) in AboutScreen

for launching actions, and the error is related to launching intents. You will need to change how the entire application launches each intent, or do something very short lived like this is just for testing:



// Starts the chosen activity
private void startARActivity()
{
    Intent i = new Intent(this, ImageTargets.class);
//    i.setClassName(mClassToLaunchPackage, mClassToLaunch);
    startActivity(i);
}

      

Your sample app should now compile and run on your phone! Now, to simplify it for any project, just follow steps 3-5.

+2


source







All Articles