Shared library problem.?

830 views
Skip to first unread message

chainz

unread,
Jul 18, 2012, 10:12:52 AM7/18/12
to andro...@googlegroups.com
My .so File Info:

"libvcsFPClient.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped."

So it was build in above environment.

Now problem is , while running the project it gives the following error log:
                                             
07-18 23:55:54.261: D/dalvikvm(638): Trying to load lib /data/data/com.example.hellojni/lib/libhello-jni.so 0x40ffa280
07-18 23:55:54.271: D/dalvikvm(638): Added shared lib /data/data/com.example.hellojni/lib/libhello-jni.so 0x40ffa280
07-18 23:55:54.271: D/dalvikvm(638): Trying to load lib /data/data/com.example.hellojni/lib/libvcsFPClient.so 0x40ffa280
07-18 23:55:54.291: W/dalvikvm(638): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/hellojni/HelloJni;
07-18 23:55:54.291: W/dalvikvm(638): Class init failed in newInstance call (Lcom/example/hellojni/HelloJni;)
07-18 23:55:54.291: D/AndroidRuntime(638): Shutting down VM
07-18 23:55:54.291: W/dalvikvm(638): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-18 23:55:54.322: E/AndroidRuntime(638): FATAL EXCEPTION: main
07-18 23:55:54.322: E/AndroidRuntime(638): java.lang.ExceptionInInitializerError
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.Class.newInstanceImpl(Native Method)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.Class.newInstance(Class.java:1319)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.ActivityThread.access$600(ActivityThread.java:130)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.os.Looper.loop(Looper.java:137)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.reflect.Method.invoke(Method.java:511)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at dalvik.system.NativeStart.main(Native Method)
07-18 23:55:54.322: E/AndroidRuntime(638): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]:    36 could not load needed library 'libusb.so' for 'libvcsFPClient.so' (load_library[1093]: Library 'libusb.so' not found)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.Runtime.loadLibrary(Runtime.java:370)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at java.lang.System.loadLibrary(System.java:535)
07-18 23:55:54.322: E/AndroidRuntime(638): 	at com.example.hellojni.HelloJni.<clinit>(HelloJni.java:69)
07-18 23:55:54.322: E/AndroidRuntime(638): 	... 15 more
07-18 23:58:36.001: I/Process(638): Sending signal. PID: 638 SIG: 9


My Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c

include $(BUILD_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE                        := vcsFPClient
LOCAL_SRC_FILES                     := libvcsFPClient.so
include $(PREBUILT_SHARED_LIBRARY)



include $(CLEAR_VARS)
LOCAL_MODULE                        := usb
LOCAL_SRC_FILES                     := libusb.so
include $(PREBUILT_SHARED_LIBRARY)

How to link prebuilt cross compiler toolchain?
How to modify further .mk file ?

My system Properties are ,

Using ubuntu 10.04 , i686 .
GCC - 4.4.3

Chris Stratton

unread,
Jul 18, 2012, 2:02:43 PM7/18/12
to android-ndk
If you actually do have an android-compatible version of libusb (which
would be atypical), try loading that from java before loading the
native library that depends on it.

If you don't, please read the documentation on how Android handles USB
host support.

Chris Stratton

unread,
Jul 19, 2012, 8:57:13 AM7/19/12
to andro...@googlegroups.com
Wbere did you get these libusb .so's and what makes you think they will work on android?
Reply all
Reply to author
Forward
0 new messages