hpi-xnor / android-image-classification

GNU General Public License v3.0
17 stars 10 forks source link

UnsatisfiedLinkError: couldn't find "libmxnet_predict.so" #1

Closed ptrblck closed 7 years ago

ptrblck commented 7 years ago

Hi,

I cloned your repository and changed the SdkVersion to 23. After building, the app crashes with the following error:

05-31 15:47:17.930 16412-16477/de.hpi.xnor_mxnet E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
                                                                   Process: de.hpi.xnor_mxnet, PID: 16412
                                                                   java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                       at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                       at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                       at java.lang.Thread.run(Thread.java:818)
                                                                    Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/de.hpi.xnor_mxnet-1/base.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_dependencies_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_0_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_1_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_2_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_3_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_4_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_5_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_6_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_7_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_8_apk.apk", zip file "/data/app/de.hpi.xnor_mxnet-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/de.hpi.xnor_mxnet-1/lib/arm64, /data/app/de.hpi.xnor_mxnet-1/base.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/de.hpi.xnor_mxnet-1/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libmxnet_predict.so"
                                                                       at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                                       at java.lang.System.loadLibrary(System.java:1076)
                                                                       at org.dmlc.mxnet.Predictor.<clinit>(Predictor.java:8)
                                                                       at de.hpi.xnor_mxnet.imageclassification.ImageNetClassifier.loadModel(ImageNetClassifier.java:65)
                                                                       at de.hpi.xnor_mxnet.imageclassification.ModelPreparationTask.doInBackground(ModelPreparationTask.java:31)
                                                                       at de.hpi.xnor_mxnet.imageclassification.ModelPreparationTask.doInBackground(ModelPreparationTask.java:11)
                                                                       at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                       at java.lang.Thread.run(Thread.java:818) 
05-31 15:47:18.968 16412-16477/de.hpi.xnor_mxnet I/Process: Sending signal. PID: 16412 SIG: 9

The project tree however shows the libmxnet_predict.so in app/jniLibs/armeabi-v7a/. The lib itself is located in app/src/main/jniLibs/armeabi-v7a/.

Do you have any idea, why the libmxnet_predict.so cannot be found on my phone?

Greets! Piotr

Bartzi commented 7 years ago

Hi Piotr,

the problem is that your phone seems to have a 64 bit processor. The library we added to the repository is compiled for 32 bit arm processors.

You can clone the BMXNet repository and amalgate the library using the 64 bit, clang toolchain. After you've done this, you can copy the resulting libmxnet_predict.so into the folder jniLibs/arm64-v8a (this should be the right name) and then it should also work on your phone.

I think we still have a compiled version of BMXNet for 64 bit arm-processors somewhere here. Once we find it, we will add it to the repository!

Hope that helps!

Bartzi commented 7 years ago

I've added a 64 Bit version of the library to the repository. It should work now for you! I'm closing this issue, if it does not work because of the same reason, please open it again!

ptrblck commented 7 years ago

Thanks! It works now :)