Error after including a 2nd JNI library to my Android project (OpenCV)

前端 未结 1 720
南方客
南方客 2021-01-25 01:02

I\'m trying to add OpenCV to an existing Android project of mine but while merging them I ran into the following error:

12-08 16:15:21.951 22052-22052/ai.inbi.fa         


        
相关标签:
1条回答
  • 2021-01-25 01:08

    The error means that the file libuvcNative.so has not been installed with your APK. This can happen for a wild variety of root causes.

    Your case is exactly same as described here. The QihanOpenSDK_1.1.8.0.aar only has an armeabi version of libuvcNative.so. The fix is to change line #15 of build.gradle to read

     abiFilters 'armeabi'
    

    But I must confess that your CMakeLists.txt puzzled me. For me,

    set_target_properties(lib_qihan PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR} /libs/QihanOpenSDK_1.1.8.0.aar)
    

    does not work. To be sincere,

    set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR} /libs/${ANDROID_ABI}/libopencv_java3.so)
    

    also does not match my books. For the latter, I believe that you simply added a space while copy/pasting the script.

    For the former, I know a special trick to have an so file from an imported aar used in native build.

    I believe that your working version not only discards all OpenCV libraries, but also does not build the libnative-lib.so. This way, cmake does never look for libuvcNative.so, but still this native lib is deployed with the APK because the aar is a compiled dependency of your app. I guess that some of the QihanOpenSDK classes explicitly calls

    System.loadLibrary("uvcNative")
    

    If your libnative-lib.so does not use external symbols from libuvcNative.so, you don't need the trick I mentioned above and don't need to mention the QihanOpenSDK at all in your CMakeLists.txt.

    0 讨论(0)
提交回复
热议问题