4

Does anyone have a run through of how to get the latest Vuforia SDK (3.0.9) working in Android Studio?

All the documentation provided is geared towards Eclipse and is outdated.

I tried importing the sample application, but that doesn't build, giving several "cannot resolve symbol.." errors (I'm guessing because I haven't included the Vuforia library (as I don't know how!)

Mr Pablo
  • 4,109
  • 8
  • 51
  • 104
  • I'm so close... Maybe I'll write the pseudo answer I finally stumbled upon. My current issue is that it all works and such, until I actually try to open a specific sample. It then flashes twice and goes back to the main samples page. – DragonJawad Dec 16 '14 at 23:36

1 Answers1

3

To get the Vuforia samples compiling:

  1. Import the Vuforia samples [should be in VUFORIA_SDK/samples/VuforiaSamples-###. If there's only a zip, then extract that]
  2. Next step is handling how the folders were imported- this is to resolve the "cannot resolve symbol" errors. The issue is that the package name doesn't match the file path, ie you have to move all the files into the base app/java directory
    • Note that this may not be necessary if Android Studio imported all the folders correctly. Skip to Step 3 if that is so
    • Note that the project pane in Android Studio compresses all the empty directories in between, which you can toggle by clicking the gear icon in the Project pane then unchecking "Compact Empty Middle Packages"
    • Currently, the files that are causing all the issues should be in app/java/samples/src/com... or somewhere very similar. The com folder needs to be moved into the root java folder, ie app/java
    • In the Project pane inside Android Studio, right click the java directory and choose "Show in Files." Navigate to where your com folder currently is as mentioned previously, and move it to app/java. Done for these errors!
  3. 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 into your project.
    • You can move this probably far more elegantly and into a proper folder, but I just personally dragged the file into a directory. Take note of this directory
  4. Finally, Android Studio needs to actually add this as a dependency
    • The easiest way to do this is to open the now-named "Project Structure" window by Ctrl+Alt+Shift+S or under the File menu along the top. Go to your app then go to the Dependencies tab.
    • Click the plus button then choose "2. File Dependency"
    • Navigate to and choose the Vuforia.jar file you imported earlier
  5. You have to include the armeabi.jar file as a dependency, just like in Step 4

Side Step: If you're explicitly using the samples app, it still may not compile. Note that whoever wrote the app explicitly tried to take advantage of Eclipse's sorting system and other Eclipse-based features. If Android Studio messed up importing all the files, you may need to do more to get the app actually compiling. You may have a (runtime) error in AboutScreen for launching Activities and the error is in regards to launching the intents. You will need to modify how the entire app launches each intent, or do something very short-term like this just for testing:

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

Now your samples app should compile and run on your phone! Now, to simplify it all for any project, just do steps 3-5.

DragonJawad
  • 1,846
  • 3
  • 20
  • 28
  • Disclaimer: The app may not still work as intend. I'm working on that this very moment. – DragonJawad Dec 16 '14 at 23:54
  • Never mind, it works! It works! After debugging the entire app and having the Activity flash and quit without even any errors in logcat, I found out the little I was missing! =D – DragonJawad Dec 17 '14 at 00:33
  • I actually got it working not long after I wrote the post haha! Now I'm trying to mash in an OBJ Loader, but I'm stuck as I dont know anything about OpenGL lol – Mr Pablo Dec 17 '14 at 13:39
  • Why hasn't Qualcomm updated anything in so long? Also, mind posting your own answer or something similar? This issue NEEDS an answer, what with all the outdated info around ;D – DragonJawad Dec 17 '14 at 16:21
  • 1
    The documentation is beyond a joke. The staff on the forums simply refer to outdated docs when you ask a question. What I did, was find a project on GitHub that had been made in Android Studio, and cloned it. I'll find the link in a mo and post it. – Mr Pablo Dec 17 '14 at 16:55
  • Thanks! I've now tried to move everything over to my current project, and now Vuforia - the actual compiled library - doesn't even initialize correctly. – DragonJawad Dec 17 '14 at 17:01
  • So what was missing? I have blinking screen too. – Dmitrijs Aug 27 '15 at 08:43
  • @Dmitrijs it was mostly that side step at the end of my answer which was the final issue. Look over how the sample app handles files in its Activity– chances are, it's not working correctly due to file accessing or such (assuming you did the other steps correctly) – DragonJawad Aug 27 '15 at 16:15
  • Note: The instructions over here http://stackoverflow.com/questions/20334041/using-android-studio-with-vuforia have a better way to include the armeabi library – DragonJawad Sep 27 '15 at 21:33