title: Opencv Android: java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "libopencv_java.so"
body: <p>UPDATES AT THE BOTTOM OF THE POST</p>
  
  <p>I am trying to use OpenCV face recognizers on android and while i was able to wrap the c++ code i couldn't make it work on a Intel Atom avd. I'm not 100% sure but i think the cause of the error in the title is that i miss the libopencv_java.so in the /lib/x86 project directory. </p>
  
  <p>Any thoughts why the lib is missing and how to get it work properly?</p>
  
  <p><img src="https://i.stack.imgur.com/ruxDX.png" alt="libopencv_java.so for x86 is missing"></p>
  
  <p>My Android.mk looks like:</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  
  include $(CLEAR_VARS)
  OPENCV_LIB_TYPE:=SHARED
  include /home/fat/Scaricati/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk
  
  LOCAL_MODULE    := FaceDetectionPerformances
  LOCAL_SRC_FILES := FaceDetectionPerformances.cpp
  FILE_LIST_CPP := $(wildcard $(LOCAL_PATH)/*.cpp) # finds all cpp files
  OPENCV_INSTALL_MODULES:=on
  
  
  include $(BUILD_SHARED_LIBRARY)
  </code></pre>
  
  <p>While my Application.mk is</p>
  
  <pre><code>APP_STL := gnustl_static
  APP_CPPFLAGS := -frtti -fexceptions
  APP_ABI := x86 armeabi armeabi-v7a
  APP_PLATFORM := android-8
  </code></pre>
  
  <p>The ndk-build log is</p>
  
  <pre><code>    18:32:16 **** Auto Build of configuration Default for project FaceDetectionPerformances ****
  /home/fat/android-ndk-r9d/ndk-build NDK_DEBUG=1 all 
  Android NDK: WARNING:jni/Android.mk:FaceDetectionPerformances: non-system libraries in linker flags: -lopencv_java    
  Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
  Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
  Android NDK:     current module    
  [x86] Gdbserver      : [x86-4.6] libs/x86/gdbserver
  [x86] Gdbsetup       : libs/x86/gdb.setup
  [armeabi] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
  [armeabi] Gdbsetup       : libs/armeabi/gdb.setup
  [armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi-v7a/gdbserver
  [armeabi-v7a] Gdbsetup       : libs/armeabi-v7a/gdb.setup
  [x86] Compile++      : FaceDetectionPerformances &lt;= FaceDetectionPerformances.cpp
  [x86] SharedLibrary  : libFaceDetectionPerformances.so
  [x86] Install        : libFaceDetectionPerformances.so =&gt; libs/x86/libFaceDetectionPerformances.so
  [armeabi] Compile++ thumb: FaceDetectionPerformances &lt;= FaceDetectionPerformances.cpp
  [armeabi] SharedLibrary  : libFaceDetectionPerformances.so
  [armeabi] Install        : libFaceDetectionPerformances.so =&gt; libs/armeabi/libFaceDetectionPerformances.so
  [armeabi] Install        : libopencv_java.so =&gt; libs/armeabi/libopencv_java.so
  [armeabi-v7a] Compile++ thumb: FaceDetectionPerformances &lt;= FaceDetectionPerformances.cpp
  [armeabi-v7a] SharedLibrary  : libFaceDetectionPerformances.so
  /home/fat/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /home/fat/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libopencv_java.so
  [armeabi-v7a] Install        : libFaceDetectionPerformances.so =&gt; libs/armeabi-v7a/libFaceDetectionPerformances.so
  [armeabi-v7a] Install        : libopencv_java.so =&gt; libs/armeabi-v7a/libopencv_java.so
  
  1
  </code></pre>
  
  <p>8:32:37 Build Finished (took 20s.952ms)</p>
  
  <p><strong>UPDATE 1</strong>
  The opencvAndroidSdk package provides the shared library libopencv_java for the x86 arch, but ndk will not move it to the libs/x86 directory at build time, while it does for armeabi arch. I also tried to move it manually from /OpenCV-2.4.9-android-sdk/sdk/native/libs/x86/libopencv_java.so to the /libs/x86 project subdirectory, but when i build the project, ndk deletes the file.</p>