Error Loading Runtime library in Android Studio

19,836

I had this same problem trying to use ZBar SDK. You most likely need to edit your build.gradle to make sure that the native libraries are included in your APK. This is how I fixed your problem: https://stackoverflow.com/a/16993006/2221876

Share:
19,836
Tariq
Author by

Tariq

Well, I have been coding in a list of programming languages for last 5.5 years. Just like some other full stack developers. But lets take it straight. I am still a beginner, a learner and a newbie. And perhaps this behavior of mine will continue till I die. However, right now I am serving as a Java Platform engineer for last 2 years after completing my graduation. SOreadytohelp

Updated on June 17, 2022

Comments

  • Tariq
    Tariq almost 2 years

    In my android project I am using an external jar library which utilizes a runtime library libiconv.so. I have the library included in my project's lib directory. The library is included for all three architectures in the following directory hirarcy.

    libs>
    armeabi>libiconv.so
    armeabi-v7a>libiconv.so
    x86>libiconv.so
    

    But I am getting Exceptions as logged by log cat:

    05-23 12:18:58.857    3081-3081/?                              E/AndroidRuntime: 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:1054)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5041)
            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:793)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
            at dalvik.system.NativeStart.main(Native Method)
            Caused by: java.lang.UnsatisfiedLinkError: Couldn't load libiconv.so from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.tariq.buynow-1.apk,libraryPath=/data/app-lib/com.tariq.buynow-1]: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:365)
            at java.lang.System.loadLibrary(System.java:535)
            at com.tariq.buynow.CameraActivity.<clinit>(CameraActivity.java:30)
    

    Where at CameraActivity.java:30 is:

    static { System.loadLibrary("libiconv.so"); }
    

    I have also tried

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

    Is it some thing to do with gradle configuration, as I am new to Android Studio, or the error source is something else?

  • samael
    samael over 10 years
    on latest version of Android Studio you just the native libraries in src/main/jniLibs and gradle will do the rest.