0

I have a rather large shared library file (= 12megabytes) which does not contain any JNI code whatsoever.

When calling System.loadLibrary("some_file") the method never returns and no relevant output is generated. Also, Windows Taskmanager reports that the emulator instance is not hogging all the CPU power.

I have a class with the following code:

static 
{
    System.out.println("Trying");
    System.loadLibrary("some_file");
    System.out.println("Works");
}

Here is the output given from LogCat:

I/System.out(534): Trying
D/dalvikvm(534): Trying to load lib /data/data/app/lib/libsome_file.so 0x40643c20

If I upload a native test application that uses the library libsome_file.so and run this from the emulator shell, then the application works.

Is there any method to debug what System.loadLibrary is doing or does anyone have some hints why System.loadLibrary might never return?

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
foens
  • 8,642
  • 2
  • 36
  • 48
  • You could get problems if you library needs other libraries, but I wouldn't expect it to hang. I assume you have tried smaller libraries successfully. – Peter Lawrey Dec 19 '11 at 14:27
  • I have tried some of the ndk-samples. They work perfectly. – foens Dec 19 '11 at 14:37

2 Answers2

1

Adding my solution in case someone else run into the problem. The problem was with some external dependencies (OpenSceneGraph) that were loaded statically in our library. They were only hanging on Android 4.0 and it was running fine 4.2 and up.

So if you have the problem, put a __android_log_print in the JNI_onLoad of your library (if you have one). If it is not called, check all the functions that can be called statically (beware, some might be hidden behind macros) and try to remove them to see if your able to load the library then.

Jean-Philippe Jodoin
  • 4,536
  • 1
  • 25
  • 28
1

I found the solution to the problem myself. I did not use any additional debug tools, but left out some code that was run when the library loaded. The particular code hanged, making System.loadLibrary hang as well.

foens
  • 8,642
  • 2
  • 36
  • 48
  • related ? http://stackoverflow.com/questions/12701940/hold-in-trying-to-load-lib-and-no-return-for-ever/17514491#17514491 – Gelldur Jul 07 '13 at 17:33