How To Troubleshoot Android Compiler and Runtime Errors

The general procedure on how to build and run a Vuforia sample application is described in this web page: How To Compile and Run a Vuforia Android Sample and Compiling and Running a Vuforia iOS Sample App

If after reading the developer guide, you still see run time or compile errors, check the issues below.

libVuforia.so could not be loaded

If you are using Vuforia SDK version 2.8 or later, you are building your own Vuforia-based project, and you have incurred into this error message: The library libVuforia.so could not be loaded.

Problem:

This error usually indicates that you have not copied the native library libVuforia.so into the /libs/armeabi-v7a folder of your Vuforia Android project.

Solution:

The Vuforia samples provide a convenient script named CopyVuforiaFiles.xml. This script automatically copies the libVuforia.so file from the Vuforia installation directory into the sample-specific /libs subfolder. However, such an automatic copy script may be missing if you are building your own project.

To fix this situation, you can manually copy libVuforia.so
from:
YOUR_VUFORIA_DIR / build / lib / armeabi-v7a /

to

YOUR_ANDROID_PROJECT_DIR / libs / armeabi-v7a

Note: If your project already contains a CopyVuforiaFiles.xml script, but for some reason this is not working (due to the location of your samples directory compared the SDK directory), you can delete the CopyVuforiaFiles.xml script and manually copy libVuforia.so as indicated above.

Unsatisfied Link Error

You observe runtime errors where the message indicates that some links are unresolved, similar to: 02-25 15:00:48.270: E/AndroidRuntime(31474): java.lang.UnsatisfiedLinkError:

The error message indicates that some libraries are missing: the library libVuforia.so could not be loaded.

Problem:

Those error messages usually indicate that you have not built the native (C++) part of your Android project.

Solution:

  1. To fix the issue you can open a command console (for example, cygwin), change the directory to your project root, and type: ndk-build
  2. After the command ndk-build has successfully built the native code, you should see the \libs folder appear under your project directory. In Eclipse, refresh your project (right-click on the project and select Refresh, or press F5). Then run the application again.
  3. If you renamed the Java package or class names, you might get an UnsatisfiedLinkError because you did not rename the C++ native functions accordingly.
    For instance, if your package name is: com.my.company.ImageTargets
    (instead of com.vuforia.samples.ImageTargets);
    and your main Java class is called: com.my.company.ImageTargets.ImageTargets (instead of com.vuforia.samples.ImageTargets.ImageTargets),then the native functions must be renamed, as in this example:

Java_com_vuforia_samples_ImageTargets_ImageTargets_initApplicationNative

must be renamed to:

Java_com_my_company_ImageTargets_ImageTargets_initApplicationNative

  1. Then run ndk-build again and refresh the Java project in Eclipse.

Could not find method

If you get a runtime error with a message similar to the following messages:

Unable to resolve static method XY:

Could not find method com.qualcomm.QCAR.QCAR.someMethod

Problem:

The problem might be with your QCAR_SDK_ROOT variable.
In this case you need to verify both of these things:

  • Whether your QCAR_SDK_ROOT has been defined
  • Whether it is pointing to the correct path.

For instance, if you upgrade to a newer version of the Vuforia SDK, the QCAR_SDK_ROOT might still point to an older version, such as V1.5.

Solution:

  1. To verify this (in Eclipse), open the Window menu and select Preferences > Java > Build Path > Classpath Variables. You should see a list of symbols that includes QCAR_SDK_ROOT.
  2. If you do not see QCARL_SDK_ROOT, add it to the list and then set its value to the path of your Vuforia library. For instance C:\Development\Android\vuforia-sdk-2-0-30\.
  3. If QCARL_SDK_ROOT is already defined, make sure that its path corresponds to the actual location of your latest Vuforia installation directory.
  4. Another cause could be that the QCAR jar file is not exported with your APK when the app is deployed on your device. To enforce that, right-click on your project, select Properties > Java Build Path > Order and Export. Make sure to check (tick) the checkbox for QCAR_SDK_ROOT; then press Apply/OK, and clean/rebuild the project.

Compliance level error

Problem:

You get the following error message when importing a Vuforia sample project into Eclipse: Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties.

Solution:

Right-click the project, and then select Android Tools > Fix Project Properties.

No matching EGL configs

Problem:

You get an error similar to the following message:
02-11 08:56:29.312: E/AndroidRuntime(878): FATAL EXCEPTION: GLThread 83
02-11 08:56:29.312: E/AndroidRuntime(878): java.lang.IllegalArgumentException: No matching EGL configs

Solution:

The most likely reason for such an error is that you are trying to run a Vuforia application on the Android emulator (on a virtual device). Vuforia requires a real device; therefore, it cannot be run on the Android emulator.

libVuforia.so: Permission denied

Problem:

You get an error message similar to the following message while compiling with ndk-build:

c:/development/android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/preb uilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-l inux-androideabi/bin/ld.exe: cannot find ./obj/local/armeabi/libQCAR.so: Permission denied

Solution:

  • You probably need to change the file permission in your Vuforia installation directory.
  • You also must ensure full read-write access to all the files. One way to do this is to browse to the Vuforia SDK root directory and type at the cygwin console: chmod -R 777 *