Installing Vuforia in Android Studio
You need to follow following Steps:
Read our Getting Started Guide for instructions on setting up the
Java SDK, Android SDK and NDK:https://developer.vuforia.com/downloads/sdk
Make sure you have installed the latest version available of Android
Studio from:http://developer.android.com/sdk/index.html
Use the Android SDK Manager (from within Android Studio) to get the
latest Android SDK and Android Platform and Build toolsLaunch Android Studio
Select File - > Import Project ... and browse to the root directory
of the sample Vuforia project you want to openProceed in the Import Wizard dialog (click Next, Next) until you
reach a page with this message:- "Alternatively, you can fill in the actual path map in the table below":
- click to edit
- enter the actual path to the Vuforia.jar library (which is located under your vuforia_install_dir/build/java/vuforia)
In the Project view, right-click on the Project and expand the view
hierarchy so to locate the Vuforia.jar under app > src > mainright-click on Vuforia.jar to open the context menu
click on the "Add as library..." option in the context menu
Alternatively, if you cannot locate the Vuforia.jar in your project
hierarchy:right-click on the Project and select, "Open Module Settings"
- select "App"
- then select the "Dependencies" tab
- Click on the "+" button to Add a File Dependency and browse to the
Vuforia.jar file
Create a folder called "jniLibs" under the "app/src/main" folder under your Android Studio project directory
- Copy the "armeabi-v7a" folder (including the libVuforia.so file
located inside it) from the "vuforia_install_dir/build/lib" to the
"app/src/main/jniLibs" folder
the resulting directory structure under your project root should be:
/app
/src
/main
/jniLibs
/armeabi-v7a
/**libVuforia.so**
- If your project includes a "jni" folder, move it to a location
outside of your project (otherwise Android Studio may attempt to
compile the sources in that folder and may fail) - Clean and rebuild the project
- Run the app on your device
Best Luck :)
Vuforia SDK and Android Studio?
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. Thecom
folder needs to be moved into the root java folder, ieapp/java
- In the Project pane inside Android Studio, right click the
java
directory and choose "Show in Files." Navigate to where yourcom
folder currently is as mentioned previously, and move it toapp/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- To create the armeabi.jar file, follow the guide here [for those parts]
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.
Incorporate vuforia android SDK in a new project
Instead of relying on Vuforia's module, I built my own real-time OCR from scratch, using the Camera (1) API and Google's Mobile Vision Library.
My app - Optical Dictionary & Vocabulary Teacher - performs a lot better than Vuforia's module. It does real-time scanning of words, shows them in a more friendly manner, and does way better validation of words. It even lemmatizes the words (e.g fooled -> fool, thieves -> thief etc).
Also, needless to say that this gave me complete control over my module as well.
Here is a Video Demo of my app.
If any one wants to build something similar, they can feel free to contact me for assistance.
Related Topics
Open Google Maps Through Intent for Specific Location in Android
Firebase Changing Layout of Child Data Information in Android
Borders on Certain Zoom Levels on Webpage
Firebase Retrieve Data Null Outside Method
Import .R Cannot Be Resolved When I Import Actionbarsherlock
Push Notification Enable and Disable by Using Switch
How to Paging Query from Firebase Using Android Firebaseui
How to Save Image Taken from Camera and Show It to Listview - Crashes with "Illegalstateexception"
Boot Broadcastreceiver Does Not Work on Xiaomi Devices
How to Develop Android App Completely Using Python
How to Listen for a Custom Uri
Eclipse Hangs at The Android Sdk Content Loader
Adding a Progress Dialog in a Webview
How Many Activities Vs Fragments
Fcm Remote Notifications Payload for iOS and Android
How to Access Adb in Os X Through Terminal, "Command Not Found"