I am using javacv for my project, in my project i want to use opencv_highui.cvLoadImage function
I have added javacv.jar,javacpp.jar in libs folder,and extract all so files in libs/armebi-v7a folder
but when i run my project it gives me error of exceptionintialization error is there any other steps to follow for opencv
Please give me some suggestion
here is me code
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
try {
cvLoadImage("mnt/sdcard/make_machine_example1.png");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
![][1] [1]: http://i.stack.imgur.com/C19pE.png i have also attached my project structure , Please suggest me
Here is the stack trace
11-21 14:49:47.673: E/AndroidRuntime(2250): java.lang.ExceptionInInitializerError
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.example.demoproject.MainActivity.onCreate(MainActivity.java:23)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.Activity.performCreate(Activity.java:4465)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.ActivityThread.access$600(ActivityThread.java:127)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.os.Looper.loop(Looper.java:137)
11-21 14:49:47.673: E/AndroidRuntime(2250): at android.app.ActivityThread.main(ActivityThread.java:4448)
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.reflect.Method.invokeNative(Native Method)
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.reflect.Method.invoke(Method.java:511)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
11-21 14:49:47.673: E/AndroidRuntime(2250): at dalvik.system.NativeStart.main(Native Method)
11-21 14:49:47.673: E/AndroidRuntime(2250): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 1418 cannot locate '_ZSt10unexpectedv'...
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.Runtime.loadLibrary(Runtime.java:370)
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.System.loadLibrary(System.java:535)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:701)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacpp.Loader.load(Loader.java:578)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacpp.Loader.load(Loader.java:532)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:79)
11-21 14:49:47.673: E/AndroidRuntime(2250): ... 15 more
11-21 14:49:47.673: E/AndroidRuntime(2250): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gnustl_static: findLibrary returned null
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.Runtime.loadLibrary(Runtime.java:365)
11-21 14:49:47.673: E/AndroidRuntime(2250): at java.lang.System.loadLibrary(System.java:535)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:701)
11-21 14:49:47.673: E/AndroidRuntime(2250): at com.googlecode.javacpp.Loader.load(Loader.java:569)
11-21 14:49:47.673: E/AndroidRuntime(2250): ... 17 more
after adding that jars from build path i have following exception
11-21 15:02:05.232: E/AndroidRuntime(17814): FATAL EXCEPTION: main
11-21 15:02:05.232: E/AndroidRuntime(17814): java.lang.ExceptionInInitializerError
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.example.demoproject.MainActivity.onCreate(MainActivity.java:23)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.os.Looper.loop(Looper.java:123)
11-21 15:02:05.232: E/AndroidRuntime(17814): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-21 15:02:05.232: E/AndroidRuntime(17814): at java.lang.reflect.Method.invokeNative(Native Method)
11-21 15:02:05.232: E/AndroidRuntime(17814): at java.lang.reflect.Method.invoke(Method.java:521)
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-21 15:02:05.232: E/AndroidRuntime(17814): at dalvik.system.NativeStart.main(Native Method)
11-21 15:02:05.232: E/AndroidRuntime(17814): Caused by: java.lang.NoSuchMethodError: java.util.Arrays.copyOf
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.googlecode.javacpp.Loader.findLibrary(Loader.java:646)
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.googlecode.javacpp.Loader.load(Loader.java:568)
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.googlecode.javacpp.Loader.load(Loader.java:532)
11-21 15:02:05.232: E/AndroidRuntime(17814): at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:79)
11-21 15:02:05.232: E/AndroidRuntime(17814): ... 14 more
Do you have any idea about it ? Thanks
Just put all the
*.so
files DIRECTLY inside your projectslibs/armeabi
directory. DO NOT put them inside any other sub-directories such as:libs/armeabi/com/googlecode/...
etcI have answered your question here. You maybe need to add the .so files in the armeabi folder too, not only armeabi-v7a. I had that problem but in the opposite way and I solved doing it.
By the way, how do you use the function? Remember that you have to put the whole name (also with the directories) if you are not working with pictures in the same folder. I would put it just in case even in that case.
I do it like this and it works: