Overview
Trying to compile a lib.so with Android NDK r9d for using native code in my Android app. Since the lib.so is a big thirdparty with lot of dependences, I have not done the typical NDK project (with Android.mk and so on); Instead, I have used the standard compile.sh that comes with the lib sources and make pertinent changes on it to use NDK toolchain.
Finally, lib.so is compiled without errors.
Problem
When I test lib.so in my Android app I get "rare" (for me) errors. Here LogCat (if somebody knows how to "expand" the "... 15 more" message, I'll do it):
04-29 11:51:47.690: E/AndroidRuntime(10029): FATAL EXCEPTION: main
04-29 11:51:47.690: E/AndroidRuntime(10029): java.lang.ExceptionInInitializerError
04-29 11:51:47.690: E/AndroidRuntime(10029): at com.shalafisoft.mediatabplus.AboutActivity.onCreate(AboutActivity.java:37)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.Activity.performCreate(Activity.java:5206)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.ActivityThread.access$600(ActivityThread.java:140)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.os.Looper.loop(Looper.java:137)
04-29 11:51:47.690: E/AndroidRuntime(10029): at android.app.ActivityThread.main(ActivityThread.java:4898)
04-29 11:51:47.690: E/AndroidRuntime(10029): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 11:51:47.690: E/AndroidRuntime(10029): at java.lang.reflect.Method.invoke(Method.java:511)
04-29 11:51:47.690: E/AndroidRuntime(10029): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
04-29 11:51:47.690: E/AndroidRuntime(10029): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
04-29 11:51:47.690: E/AndroidRuntime(10029): at dalvik.system.NativeStart.main(Native Method)
04-29 11:51:47.690: E/AndroidRuntime(10029): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1307]: 1918 cannot locate '_ZNSbIwSt11char_traitsIwESaIwEE6resizeEjw'...
04-29 11:51:47.690: E/AndroidRuntime(10029): at java.lang.Runtime.loadLibrary(Runtime.java:370)
04-29 11:51:47.690: E/AndroidRuntime(10029): at java.lang.System.loadLibrary(System.java:535)
04-29 11:51:47.690: E/AndroidRuntime(10029): at com.shalafisoft.mediainfo.MediaInfoLib.<clinit>(MediaInfoLib.java:6)
04-29 11:51:47.690: E/AndroidRuntime(10029): ... 15 more
Here the class to load the library (line 6 is LoadLibrary).
public class MediaInfoLib {
static {
System.loadLibrary("mediainfoMIO");
}
public native String pruebaJNI();
}
Thigs I have found or done
- I have googled the id _ZW... and it seems to be related with /usr/lib32/libstdc++.so. This is all I know.
- I have googled the error and sometimes people say is something related with arch; I usually put lib.so inside libs/armeabi but I have tried libs/armeabi-v7a too with same result.
More details
- For compiling lib.so I use Ubuntu 12.10 x86 with Android NDK r9d
- For programming Android app I use Eclipse ADT under Windows 8 x64
- For testing Android app I use my phone Samsung Galaxy S3 (no emulator)