How to load native library on android?

11,097

Solution 1

"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.

Solution 2

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

Share:
11,097
Arsen Zahray
Author by

Arsen Zahray

Updated on June 04, 2022

Comments

  • Arsen Zahray
    Arsen Zahray almost 2 years

    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?