-1

As title says : i want to add existing libocr.so to my android project. I have just created /libs/armeabi/libocr.so in project root and i want to add it as library.

thanks

dmytrodanylyk : i have tried your solution but when i tried to perform System.loadLibrary("ocr");

exception occured :


02-21 16:50:52.799: ERROR/AndroidRuntime(15073): FATAL EXCEPTION: main
02-21 16:50:52.799: ERROR/AndroidRuntime(15073): java.lang.ExceptionInInitializerError
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at net.gummo.OCRTestActivity.onCreate(OCRTestActivity.java:20)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.ActivityThread.access$2300(ActivityThread.java:135)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.os.Looper.loop(Looper.java:144)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at android.app.ActivityThread.main(ActivityThread.java:4937)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at java.lang.reflect.Method.invokeNative(Native Method)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at java.lang.reflect.Method.invoke(Method.java:521)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at dalvik.system.NativeStart.main(Native Method)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073): Caused by: java.lang.UnsatisfiedLinkError: Library ocr not found
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at java.lang.Runtime.loadLibrary(Runtime.java:461)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at java.lang.System.loadLibrary(System.java:557)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     at net.gummo.OCR.(OCR.java:1067)
02-21 16:50:52.799: ERROR/AndroidRuntime(15073):     ... 14 more 


falconseye
  • 187
  • 2
  • 5
  • 16

1 Answers1

1

Here is example:

public static boolean loadNativeLibrary() {

    try {

        Log.i(TAG, "Attempting to load library: " + LIBRARY_NAME);
        System.loadLibrary(LIBRARY_NAME);

    } catch (Exception e) { 
        Log.i(TAG, "Exception loading native library: " + e.toString());
        return false;
    }

    return true;
}
Dmytro Danylyk
  • 19,684
  • 11
  • 62
  • 68
  • dmytrodanylyk : does it matter where is libocr.so located in project or it has to be in root or some special folder like libs. lib or else? – falconseye Feb 20 '12 at 21:06
  • The .so library files typically go in the project_root_dir/libs subfolder. Also, generally they are in further subfolders that describe their architecture (e.g. project_root_dir/libs/armeabi/libpdfview2.so). – Dmytro Danylyk Feb 21 '12 at 11:34
  • Try to use search first: http://stackoverflow.com/questions/8650472/how-do-i-import-a-native-library-so-file-into-eclipse – Dmytro Danylyk Feb 21 '12 at 11:34