user2017023
user2017023

Reputation: 81

opencv4android samples compile but do not run

I'm following the tutorial for trying out opencv4android found here There are several samples provided. After getting OpenCV-2.4.3.2-android-sdk and installing the manager on my device, I imported the sample files in eclipse and they all compiled successfully. However, any sample I try immediately crashes on my device. For instance, if I run the "15 puzzle" example, I get the following errorlog

"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"

I'm unsure what I'm doing wrong, since this is consistent across any opencv sample I try. Thanks in advance for the help

Upvotes: 1

Views: 339

Answers (1)

user2017023
user2017023

Reputation: 81

If anyone else runs into a similar problem, the solution in my case was simply to compile against java 6, not java 7. Compiling against java 7 doesn't work for opencv4android at the time I'm writing this post.

Upvotes: 1

Related Questions