To get the Vuforia samples compiling:
- Import the Vuforia samples [should be in
VUFORIA_SDK/samples/VuforiaSamples-###
. If there's only a zip, then extract that]
- 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!
- 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
- 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
- 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.