opencv4android 示例编译但不运行
Posted
技术标签:
【中文标题】opencv4android 示例编译但不运行【英文标题】:opencv4android samples compile but do not run 【发布时间】:2013-01-28 05:22:11 【问题描述】:我正在按照此处找到的试用 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 ComponentInfoorg.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 示例中都是一致的。提前感谢您的帮助
【问题讨论】:
【参考方案1】:如果其他人遇到类似问题,我的解决方案只是针对 java 6 而不是 java 7 进行编译。在我写这篇文章时,针对 java 7 的编译不适用于 opencv4android。
【讨论】:
以上是关于opencv4android 示例编译但不运行的主要内容,如果未能解决你的问题,请参考以下文章