我正在按照教程尝试 opencv4android 在这里提供了几个示例。在获得OpenCV-2.4.3.2-android-sdk并在我的设备上安装管理器后,我在eclipse中导入了示例文件,它们都编译成功。但是,我尝试的任何示例都会立即在我的设备上崩溃。 例如,如果我运行"15 拼图"示例,我会得到以下错误日志
"01-27 23:11:50.523: E/AndroidRuntime(21568): FATAL EXCEPTION: main
01-27 23:11:50.523: E/AndroidRuntime(21568): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.opencv.samples.puzzle15/org.opencv.samples.puzzle15.Puzzle15Activity}: java.lang.ClassNotFoundException: org.opencv.samples.puzzle15.Puzzle15Activity
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1973)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2083)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread.access$600(ActivityThread.java:134)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.os.Looper.loop(Looper.java:137)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread.main(ActivityThread.java:4722)
01-27 23:11:50.523: E/AndroidRuntime(21568): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 23:11:50.523: E/AndroidRuntime(21568): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 23:11:50.523: E/AndroidRuntime(21568): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
01-27 23:11:50.523: E/AndroidRuntime(21568): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
01-27 23:11:50.523: E/AndroidRuntime(21568): at dalvik.system.NativeStart.main(Native Method)
01-27 23:11:50.523: E/AndroidRuntime(21568): Caused by: java.lang.ClassNotFoundException: org.opencv.samples.puzzle15.Puzzle15Activity
01-27 23:11:50.523: E/AndroidRuntime(21568): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-27 23:11:50.523: E/AndroidRuntime(21568): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-27 23:11:50.523: E/AndroidRuntime(21568): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-27 23:11:50.523: E/AndroidRuntime(21568): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1964)
01-27 23:11:50.523: E/AndroidRuntime(21568): ... 11 more"
我不确定我做错了什么,因为这在我尝试的任何 opencv 样本中都是一致的。提前感谢您的帮助
如果其他人遇到类似的问题,在我的情况下,解决方案只是针对java 6进行编译,而不是java 7。在我写这篇文章的时候,针对java 7编译不适用于opencv4android。