3

我正在尝试从 opencv for android 运行一个示例。它不工作。

 java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{org.opencv.samples.puzzle15/org.opencv.samples.
puzzle15.Puzzle15Activity}: java.lang.ClassNotFoundException: Didn't find class
"org.opencv.samples.puzzle15.Puzzle15Activity" on path:
DexPathList[[zip file "/data/app/org.opencv.samples.puzzle15-
 1.apk"],nativeLibraryDirectories=
[/data/app-lib/org.opencv.samples.puzzle15-1, /vendor/lib, /system/lib]]

这是什么意思,我该如何解决?我想要具体的步骤来解决它。

完整日志:

     10-25 14:03:09.794: E/AndroidRuntime(958): FATAL EXCEPTION: main
     10-25 14:03:09.794: E/AndroidRuntime(958): java.lang.RuntimeException: Unable to     
     instantiate activity ComponentInfo{org.opencv.samples.puzzle15/
     org.opencv.samples.puzzle15.Puzzle15Activity}: java.lang.ClassNotFoundException:      
     Didn't find class "org.opencv.samples.puzzle15.Puzzle15Activity" on path:  
     /data/app/org.opencv.samples.puzzle15-2.apk
     10-25 14:03:09.794: E/AndroidRuntime(958):     at    
     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at   
     android.app.ActivityThread.access$600(ActivityThread.java:141)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     android.os.Handler.dispatchMessage(Handler.java:99)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     android.os.Looper.loop(Looper.java:137)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     android.app.ActivityThread.main(ActivityThread.java:5041)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     java.lang.reflect.Method.invokeNative(Native Method)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     java.lang.reflect.Method.invoke(Method.java:511)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at     
     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
     10-25 14:03:09.794: E/AndroidRuntime(958):     at 
     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
     10-25 14:03:09.794: E/AndroidRuntime(958): dalvik.system.NativeStart.main(NativeMethod)
     10-25 14:03:09.794: E/AndroidRuntime(958): Caused by: java.lang.ClassNotFoundException: 
     Didn't find class "org.opencv.samples.puzzle15.Puzzle15Activity" on path: 
    /data/app/org.opencv.samples.puzzle15-2.apk
    10-25 14:03:09.794: E/AndroidRuntime(958):  at 
    dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
    10-25 14:03:09.794: E/AndroidRuntime(958):  at 
    java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    10-25 14:03:09.794: E/AndroidRuntime(958):  at 
    java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    10-25 14:03:09.794: E/AndroidRuntime(958):  at 
    android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    10-25 14:03:09.794: E/AndroidRuntime(958):  at 
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
4

1 回答 1

0

从此OpenCV for android导入并下载ADT Bundle

而不是这个:

   Warning : After the initial import, on a non-Windows (Linux and Mac OS) operating system Eclipse will still show build errors for applications with native C++ code. To resolve the issues, please do the following:
Open Project Properties -> C/C++ Build, and replace “Build command” text to "${NDKROOT}/ndk-build" (remove .cmd at the end).

尝试以下步骤:

下载 ndk build Android NDK

指定 NDK 位置:

Windows >>> 首选项 >> Android >> NDK >> 设置 NDK 的位置(你已经从上面的链接下载了)

获取项目位置:

右键单击项目>>>属性>>资源>>位置

例如:位置:D:\OpenCV-2.4.6-android-sdk-r2\OpenCV-2.4.6-android-sdk\samples\15-puzzle

使用 cmd 构建项目:

D:\OpenCV-2.4.6-android-sdk-r2\OpenCV-2.4.6-android-sdk\samples\15-puzzle>D:\android-ndk-r9\ndk-build

D:\android-ndk-r9\ndk-build(你的 NDK 路径)

注意:确保你已经包含了库项目并安装了 OpenCV 管理器

于 2013-10-30T07:20:16.210 回答