Log in or register to post comments

The library lib*.so could not be loaded (System.loadLibrary)

December 16, 2010 - 8:07pm #1

Sorry for the stupid question...
Our team are developing on a Android app using ImageTargets and its Shared library, and we have modified the code(Native and Java codes) a lot on both projects.
for some reasons:confused: ,when launching the apps on my HTC desire, It crash at the first moment because it didn't load the library properly (all the library can't be loaded).Here's some ERROR MESSAGE in logcat:

12-17 11:41:20.014: INFO/ActivityManager(103): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.qualcomm.QCARSamples.ImageTargets/.ImageTargets }
12-17 11:41:20.024: DEBUG/PhoneWindow(1705): couldn't save which view has focus because the focused view android.webkit.WebView@45ffa530 has no id.
12-17 11:41:20.034: DEBUG/AndroidRuntime(2633): Shutting down VM
12-17 11:41:20.034: DEBUG/dalvikvm(2633): Debugger has detached; object registry had 1 entries
12-17 11:41:20.054: INFO/AndroidRuntime(2633): NOTE: attach of thread 'Binder Thread #3' failed
12-17 11:41:20.074: ERROR/MediaScannerService(362): Failed to delete file /data/data/com.android.providers.media/pause_scan
12-17 11:41:20.074: INFO/ActivityManager(103): Start proc com.qualcomm.QCARSamples.ImageTargets for activity com.qualcomm.QCARSamples.ImageTargets/.ImageTargets: pid=2641 uid=10077 gids={1006, 3003}
12-17 11:41:20.164: ERROR/QCAR(2641): The library libQCAR.so could not be loaded
12-17 11:41:20.164: DEBUG/dalvikvm(2641): Trying to load lib /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so 0x46059270
12-17 11:41:20.164: INFO/dalvikvm(2641): Unable to dlopen(/data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so): Cannot load library: link_image[1995]: failed to link libImageTargets.so
12-17 11:41:20.164: ERROR/QCAR(2641): The library libImageTargets.so could not be loaded
12-17 11:41:20.164: DEBUG/QCAR(2641): QCARSampleActivity::onCreate

....

12-17 11:41:20.614: WARN/dalvikvm(2641): No implementation found for native Lcom/qualcomm/QCARSamples/ImageTargets/ImageTargets;.getOpenGlEsVersionNative ()I
12-17 11:41:20.614: DEBUG/AndroidRuntime(2641): Shutting down VM
12-17 11:41:20.614: WARN/dalvikvm(2641): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
12-17 11:41:20.624: ERROR/AndroidRuntime(2641): FATAL EXCEPTION: main
12-17 11:41:20.624: ERROR/AndroidRuntime(2641): java.lang.UnsatisfiedLinkError: getOpenGlEsVersionNative

....

12-17 11:41:21.204: ERROR/MediaScannerService(362): Failed to delete file /data/data/com.android.providers.media/pause_scan

12-17 11:41:24.334: ERROR/MediaScannerService(362): Failed to delete file /data/data/com.android.providers.media/pause_scan

I have NO IDEA why it can't be loaded, it usually happens when:
1. person A commit the project.
2. person B update its project from repository, and compile correctly(ndk-build, clean, refresh)....but CRASH when launching the app.

But sometime the bug disapear for no reason?!(e.g. I arbitrarily enter a newline on the Android.mk)

I am not very familiar with the shared library linking mechanism. Is there any clue or hint that I can trace? Or some step I miss when building the whole project?:confused:

some other hints:
1. the emulator works properly (I mean it can load libraries ,but cannot run AR of cource)
2. I have modified libShared.so libImageTargets.so
3. loadLibrary function in JAVA always retuen UnsatisfiedLinkError excpetion
4. I can't open /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so in the device directory (the directory is empty)
5. print the error massage by putting this statement ( Log.e("JSRF", ulee.toString());) get the following message:
ERROR/JSRF(9773): java.lang.UnsatisfiedLinkError: Library QCAR not found
6. Our team share only one HTC desire for app development

The library lib*.so could not be loaded (System.loadLibrary)

November 28, 2013 - 3:54am #4

Hi,

 

i am unable to get this two jar files libImageTargets.so  and libTextReco.so files can you give me any idea

Re: The library lib*.so could not be loaded (System.loadLibrary)

December 17, 2010 - 6:40am #3

(my OS is Windows)
Thanks a lot!Problem Solved! I finally figure out what happened to my project build process...

Just like you said, ndk-build will remove QCAR.so , so the ORDER between the "ndk-build" and "copyQCARLibs.bat" MATTERS.

At first I feel tired of "open Cygwin window=>ndk-clean=>ndk-build" so I created a Eclipse external builder to automatically build libShared.so , like the Share project does the "copyQCARLibs.bat" things~

The key problem is that: even though I put "ndk-build builder" BEFORE "copyQCARLibs.bat builder", doesn't mean it will guarantee to run copyQCARLibs.bat AFTER finishing ndk build. Eclipse will launch the next builder without waiting current builder to finish.:mad:

So I merge two builder together to guarantee the order between them (write a shell script after ndk build).

here's the solution share to everybody :)

--login -c "cd '${build_project}' && ndk-build clean && ndk-build && .externalToolBuilders/copyQCARLibs.sh"

===============file copyQCARLibs.sh=============
#!/bin/bash
mkdir -p libs/armeabi libs/armeabi-v7a
cp ../../build/lib/armeabi/libQCAR.so libs/armeabi/
cp ../../build/lib/armeabi-v7a/libQCAR.so libs/armeabi-v7a/
if [ -f "libs/armeabi-v7a/libQCAR.so" -a -f "libs/armeabi/libQCAR.so" ]; then
ECHO ========================================================================
ECHO QCAR-SDK: libQCAR.so succesfully copied into Shared/libs directories!
ECHO ========================================================================
else
ECHO ========================================================================
ECHO ERROR: libQCAR.so could not be copied! Check your QCAR-SDK installation!
ECHO ========================================================================
fi
===============================================

Re: The library lib*.so could not be loaded (System.loadLibrary)

December 17, 2010 - 5:48am #2

So, as I think you've noticed, these are the important error messages:

- The library libQCAR.so could not be loaded
- The library libImageTargets.so could not be loaded

This typically happens when those two .so files are missing in the Eclipse build. In Eclipse, when you expand the libs folder you should see two directories, armeabi and armeabi-v7a. Each of those should contain both .so files.

Whenever you run ndk-build in the ImageTargets directory, both of these files will be deleted before libImageTargets.so is added. In Eclipse, you should be able to Refresh the project (right-click in Package Explorer and choose refresh) to see the libImageTargets.so file.

Now the Eclipse builder needs to kick in to copy the libQCAR.so file over. What operating system are you developing on? In Windows, this is a .bat file, on Mac or Linux you need to write your own shell script to match that functionality. That script should run as part of the automated build, or after a Clean of the project.

If both .so files are present and you are still seeing this error, let me know. That would be a new situation we haven't seen before.

- Kim

Log in or register to post comments