java.lang.ExceptionInInitializerError Caused by: java.lang.UnsatisfiedLinkError: Library not found

瘦欲@ 提交于 2020-01-01 20:24:48

问题


I have existing code in c and c++. I have added these c files and cpp files in Android.mk file. And I have successfully created the .so files named itv.so in my application. But now when I am trying to run Android application It is showing error like...

12-20 13:26:31.362: E/AndroidRuntime(716): FATAL EXCEPTION: main
12-20 13:26:31.362: E/AndroidRuntime(716): java.lang.ExceptionInInitializerError
12-20 13:26:31.362: E/AndroidRuntime(716):  at com.example.Internet_TV12.onCreate(Internet_TV12.java:38)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.os.Looper.loop(Looper.java:123)
12-20 13:26:31.362: E/AndroidRuntime(716):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 13:26:31.362: E/AndroidRuntime(716):  at java.lang.reflect.Method.invokeNative(Native Method)
12-20 13:26:31.362: E/AndroidRuntime(716):  at java.lang.reflect.Method.invoke(Method.java:521)
12-20 13:26:31.362: E/AndroidRuntime(716):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 13:26:31.362: E/AndroidRuntime(716):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 13:26:31.362: E/AndroidRuntime(716):  at dalvik.system.NativeStart.main(Native Method)
12-20 13:26:31.362: E/AndroidRuntime(716): Caused by: java.lang.UnsatisfiedLinkError: Library itv not found
12-20 13:26:31.362: E/AndroidRuntime(716):  at java.lang.Runtime.loadLibrary(Runtime.java:461)
12-20 13:26:31.362: E/AndroidRuntime(716):  at java.lang.System.loadLibrary(System.java:557)
12-20 13:26:31.362: E/AndroidRuntime(716):  at com.example.Display.<clinit>(Display.java:69)
12-20 13:26:31.362: E/AndroidRuntime(716):  ... 14 more

I don't know why this error is coming. I have seen lib folder which is having libitv.so file. I have also tried

static {
         try {
             System.loadLibrary("itv");
           // System.load("/data/data/com/example/lib/itv.so");
         }
         catch (UnsatisfiedLinkError use) {
                Log.e("JNI", "WARNING: Could not load itv.so");
            }
        }

But getting same error. Can anybody please tell me the solution for this error. Thank you in Advance.


回答1:


The library will be recognised if its name is libitv.so and is placed in libs\armeabi directory in your application directory, before the .apk is built.

Sometimes when the library is not copied completely(partial copy), due to some system issues the partial library too will not be recognized.




回答2:


Try naming the actual file libitv.so (lib + library name + .so) and putting it in an armeabi folder of your libs directory



来源:https://stackoverflow.com/questions/8585929/java-lang-exceptionininitializererror-caused-by-java-lang-unsatisfiedlinkerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!