3

I've got a .so library, which I've extracted from an other APK.

I've copied it into /libs/armeabi location in my project.

In my class, I'm loading it with

static {
    System.loadLibrary("mylib"); 
}

The app crashes with

08-03 07:52:08.089: E/AndroidRuntime(932): FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1319)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load mylib: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.example.mytestandroidapp.MainActivity.<clinit>(MainActivity.java:11)
08-03 07:52:08.089: E/AndroidRuntime(932):  ... 15 more

I'm doing this in eclipse.

Here's the screen of the layout of my project:

enter image description here

What should I do for this to start working?

Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224

3 Answers3

3

rename mylib.so in libmylib.so, and run your programm again (without modify the loadLibrary argument)

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • Refresh and rebuild the project once you do that :) Also, open the APK with an archiver (rename to ZIP if necessary), make sure the library file is really there. – Seva Alekseyev Aug 03 '12 at 15:09
2

"rename mylib.so in libmylib.so, and run your programm again (without modify the loadLibrary argument)" from blackbelt

+

The folder libs/armeabi-v7a should also contain the libmylib.so library. If your phone is a new one, he will check there for libraries.

0

Try the lib location path refer to:

context.getApplicationInfo().dataDir + "/lib"

and if you use API level 9, alternatively directly go to the lib directory with

context.getApplicationInfo().nativeLibraryDir

Munawir
  • 3,346
  • 9
  • 33
  • 51
Artis JIANG
  • 61
  • 1
  • 7