0

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.

geeta
  • 689
  • 3
  • 17
  • 33

2 Answers2

7

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.

Deepak
  • 1,101
  • 9
  • 14
  • Thanks for reply... This may be the reason... But how can I resolve this problem... Can u please tell me? – geeta Dec 21 '11 at 07:22
  • To be sure can you check the sizes of the libraries in the place you built and the path you copied to? – Deepak Dec 21 '11 at 10:35
2

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

zienkikk
  • 2,404
  • 1
  • 21
  • 28
  • 1
    Thanks for your reply. I have tried by actual file name libitv.so... But Same error I am getting... – geeta Dec 21 '11 at 07:20
  • If so then your extension may need to be .jnilib or .dylib as per http://stackoverflow.com/questions/3621158/jni-unsatisfiedlinkerror-loadlibrary-always-fails – zienkikk Dec 21 '11 at 07:31
  • Thanks once again for reply.. My application was working fine when I have added few c files in Android.mk file. for increasing the functionality of my application I have just added some another c and cpp files and created .so files. But now getting this error... – geeta Dec 21 '11 at 07:47