我正在尝试通过以下方式从我的项目的 MainActivity 加载预构建本机共享库:
static
{
System.loadLibrary("mylib.so"); // I have tried this way
//System.loadLibrary("libmylib.so"); // Also tried this way
//System.loadLibrary("mylib"); // Also tried this way
}
但它总是抛出以下异常:
异常前警告:
07-12 11:08:36.019: W/dalvikvm(21552): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/libtest/src/MainActivity;
07-12 11:08:42.790: W/dalvikvm(21552): Class init failed in newInstance call (Lcom/libtest/src/MainActivity;)
07-12 11:08:47.067: D/AndroidRuntime(21552): Shutting down VM
07-12 11:08:47.067: W/dalvikvm(21552): threadid=1: thread exiting with uncaught exception (group=0x40015560)
然后异常:
07-12 11:08:47.167: E/AndroidRuntime(21552): FATAL EXCEPTION: main
07-12 11:08:47.167: E/AndroidRuntime(21552): java.lang.ExceptionInInitializerError
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstanceImpl(Native Method)
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstance(Class.java:1409)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Looper.loop(Looper.java:130)
本机共享库将“libs\armeabi\mylib.so”放在我的项目文件夹下。
请帮助我我做错了什么?