-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code crashes while calling native methods #6
Comments
I noticed that, you've changed the package name to
While you did not change the package of native methods in jni part, thus the native methods cannot be found on java side. |
I changed the package name but it's not work even. There is no caffe-mobile/libs/armeabi-v7a/*.so, So copy .so file from caffe-android-demo. |
If you wanna change the package name, you should build the lib on your own, i.e. |
but log "Print : Model loaded successfully" is not printed :( |
Do you have native logs on logcat? |
these are the logs : |
Do you use the latest one (7945cce)? obj.enableLog(true); |
Thanks sh1r0 for ur reply........ copy caffe-mobile/libs/armeabi-v7a/*.so to your jni lib directory There were no .so files formed in this location, so i copied the .so files from the demo project and pasted in jni lib directory. |
Code above loadModel is public class MainActivity extends Activity {
|
Did you build your own libs? Is there any problem? |
No i just build caffe-android-lib using build.py script. |
Sorry, I have no idea with such little information. Please provide the logs during building. |
This is the only logcat that is generated. 04-20 21:59:47.422: E/Trace(10796): error opening trace file: No such file or directory (2) If you want i can upload the project on gmail and share with you, please provide your gmail id. |
You seemed to paste the logs from logcat (Android), instead of the building logs. |
i followed https://github.com/sh1r0/caffe-android-lib#build when i run build.py i got these error : and |
Then what do the logs look like? If the building is done without any errors, your shell should output messages like below.
|
i followed https://github.com/sh1r0/caffe-android-lib#build when i run build.py i got these error : and |
Which ndk version do you use? |
I'm using android-ndk-r10 |
I tried to build using android-ndk-r9, but got this : inflating: OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/videostab/optical_flow.hpp |
AFAIK, both r9, r10 are okay.
|
My protobuf/jni folder has all the files and folders mentioned above. So it seems protobuf is downloaded correctly |
Could you try to manually run |
I tried to manually build protobuf, and it compiles well and .so files are formed in local/libs |
So, do you have |
There is no libs folder in caffe-mobile |
Hmm... Actually, protobuf is one of the dependencies, and thus you need to re-run |
I run ./build.py several times but getting same error every time : Traceback (most recent call last): |
Could you provide the details about how you build, e.g. your commands? |
I tried to build again from scratch using your script build.py, and i got these messages at the last. /home/caffe/caffe-android-lib/caffe-mobile/jni/../../Boost-for-Android/build/lib//libboost_thread-gcc-mt-1_55.a(thread.o):thread.cpp:function non-virtual thunk to boost::exception_detail::bad_alloc_::~bad_alloc_(): warning: relocation refers to discarded section |
Yep, those warnings can be bypassed. 👍 |
Hi sh1r0, package com.sh1r0.caffe_android_demo; import android.support.v7.app.ActionBarActivity; @SuppressLint("SdCardPath")
} while building this time, all .so files were generated properly which and i pasted them from caffe-mobile/libs/armeabi-v7a/*.so to jni lib directory My device has all the required stuff like prototxt, solver and .model file. But still when i run the code i dont see any toast or log file, but still the app is not crashing, can u suggest what's going wrong and how can i get the results. |
Could you provide the logs? Or, please try caffe-android-demo first to see if there is any problem. |
Logs are same still same as earlier 04-24 13:21:51.552: E/Trace(13701): error opening trace file: No such file or directory (2) But i will try caffe-android-demo .... |
Caffe-android-demo works good on my device. |
AFAIW, in Android Studio projects, |
I have been following
https://github.com/sh1r0/caffe-android-lib/blob/master/README.md
and as i run this
caffeMobile.loadModel(modelPath, weightsPath);
Code crashes with following logcat
04-20 18:06:07.692: D/dalvikvm(9250): Trying to load lib /data/data/com.example.caffendk/lib/libcaffe.so 0x41496e98
04-20 18:06:07.782: D/dalvikvm(9250): Added shared lib /data/data/com.example.caffendk/lib/libcaffe.so 0x41496e98
04-20 18:06:07.782: D/dalvikvm(9250): No JNI_OnLoad found in /data/data/com.example.caffendk/lib/libcaffe.so 0x41496e98, skipping init
04-20 18:06:07.782: D/dalvikvm(9250): Trying to load lib /data/data/com.example.caffendk/lib/libcaffe_jni.so 0x41496e98
04-20 18:06:07.792: D/dalvikvm(9250): Added shared lib /data/data/com.example.caffendk/lib/libcaffe_jni.so 0x41496e98
04-20 18:06:07.832: W/dalvikvm(9250): No implementation found for native Lcom/example/caffendk/CaffeMobile;.loadModel:(Ljava/lang/String;Ljava/lang/String;)I
04-20 18:06:07.832: D/AndroidRuntime(9250): Shutting down VM
04-20 18:06:07.832: W/dalvikvm(9250): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
04-20 18:06:07.842: E/AndroidRuntime(9250): FATAL EXCEPTION: main
04-20 18:06:07.842: E/AndroidRuntime(9250): java.lang.UnsatisfiedLinkError: Native method not found: com.example.caffendk.CaffeMobile.loadModel:(Ljava/lang/String;Ljava/lang/String;)I
04-20 18:06:07.842: E/AndroidRuntime(9250): at com.example.caffendk.CaffeMobile.loadModel(Native Method)
04-20 18:06:07.842: E/AndroidRuntime(9250): at com.example.caffendk.MainActivity.onCreate(MainActivity.java:25)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.Activity.performCreate(Activity.java:5008)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.os.Looper.loop(Looper.java:137)
04-20 18:06:07.842: E/AndroidRuntime(9250): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-20 18:06:07.842: E/AndroidRuntime(9250): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 18:06:07.842: E/AndroidRuntime(9250): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 18:06:07.842: E/AndroidRuntime(9250): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-20 18:06:07.842: E/AndroidRuntime(9250): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-20 18:06:07.842: E/AndroidRuntime(9250): at dalvik.system.NativeStart.main(Native Method)
I desperately need to run caffe on android, so can somebody suggest me what's going wrong.
The text was updated successfully, but these errors were encountered: