异常初始化错误javacv

时间:2013-11-21 06:29:13

标签: android javacv

我正在为我的项目使用javacv, 在我的项目中我想使用opencv_highui.cvLoadImage函数

我在libs文件夹中添加了javacv.jar,javacpp.jar,并提取了所有这些文件 在libs / armebi-v7a文件夹中

但是当我运行我的项目时,它给出了异常初始化错误的错误 是否有任何其他步骤要遵循opencv

请给我一些建议

这是我的代码

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 我还附上了我的项目结构,请建议我

这是堆栈跟踪

    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

你对此有任何想法吗? 谢谢

2 个答案:

答案 0 :(得分:0)

我已回答了您的问题here。 您可能还需要在armeabi文件夹中添加.so文件,而不仅仅是armeabi-v7a。 I had that problem但是却以相反的方式解决了这个问题。

顺便问一下,你如何使用这个功能?请记住,如果您不使用同一文件夹中的图片,则必须输入整个名称(也包括目录)。我会把它放在以防万一的情况下。

我这样做是有效的:

cvLoadImage("/storage/sdcard0/Download/testpicture.JPG");

答案 1 :(得分:0)

将所有*.so文件直接放在项目libs/armeabi目录中。请勿将它们放在任何其他子目录中,例如:libs/armeabi/com/googlecode/...