0

I am currently working on an android app.

I am using Android NDK to run opencv in C++

Everything was working until when I imported tensorflow to detect rotation of images (an image classifier). The tensorflow code is running fine (I have tested it in another android project) but when I am combing both the codes I am getting error. Please help my project is lagging due to this.

I have checked tensorflow github repo similar issues have stated but no solution found there.

    --------- beginning of crash

10-09 22:21:15.572 7387-7387/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.baurasia.pranav.digimother, PID: 7387 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/base.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_resources_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/lib/arm64, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/base.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_resources_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.baurasia.pranav.digimother-0NgVxe-pLiV2LPUwElaVZQ==/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libopencv_java3.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at com.scanlibrary.ScanActivity.(ScanActivity.java:126) at java.lang.Class.newInstance(Native Method) at android.app.Instrumentation.newActivity(Instrumentation.java:1174) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2891) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3078) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:187) at android.app.ActivityThread.main(ActivityThread.java:7025) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:514) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)

  • 1
    What error do you get? – Dmitrii Z. Oct 08 '18 at 08:45
  • I updated the question with the logs and the error is couldn't find "libopencv_java3.so" at java.lang.Runtime.loadLibrary0(Runtime.java:1011) at java.lang.System.loadLibrary(System.java:1657) at com.scanlibrary.ScanActivity. – Pranav Baurasia Oct 09 '18 at 16:54
  • But the app was running with opencv in the first place. – Pranav Baurasia Oct 09 '18 at 16:57
  • Unzip your apk and check `lib` folder. It could be that you have all libraries for arm7 but only few for arm64 or x86. In that case you will need to specify ABIs you use or add libraries for all ABIs. – Dmitrii Z. Oct 10 '18 at 06:57
  • https://imgur.com/a/JqcXlAX this is my project structure. Every folder is having all the .so files – Pranav Baurasia Oct 10 '18 at 10:35
  • You are missing libopencv_java3 for arm64-v8a. As I said earlier you either need to add it or disable arm64-v8a using split ABI – Dmitrii Z. Oct 10 '18 at 12:55
  • If you extracted your APK as I said earlier - you would've seen that your apk in addition to those ABIs you have in your jniLibs has another directory arm64-v8a (which was added automatically as soon as you add a library which has native library for that ABI). – Dmitrii Z. Oct 10 '18 at 12:57
  • how to disable it can you provide the code which I have to put in gradle module app? – Pranav Baurasia Oct 10 '18 at 17:05
  • I tried to put the libopencv_java3 file in arm64-v8a but now it's showing error that libscanner.so file which should be present due to importing library is not. – Pranav Baurasia Oct 10 '18 at 17:40
  • [how to remove arm64 from your app](https://stackoverflow.com/questions/30782848/how-to-use-32-bit-native-libraries-on-64-bit-android-device/30799825#30799825). You will need every native library to be built for arm64 if you want to support that (note that you will need to do that in order to put your app into google play). – Dmitrii Z. Oct 10 '18 at 18:10

0 Answers0