我正试图在一个航空项目中使用JavaCV。我构建了一个本机扩展,它编译得很好,但是在运行时我得到了以下错误:
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
I/dalvikvm(16234): Could not find method java.awt.image.BufferedImage.getSampleModel, referenced from method org.bytedeco.javacpp.helper.opencv_core$AbstractIplImage.createFrom
W/dalvikvm(16234): VFY: unable to resolve virtual method 8824: Ljava/awt/image/BufferedImage;.getSampleModel ()Ljava/awt/image/SampleModel;
D/dalvikvm(16234): VFY: replacing opcode 0x6e at 0x0004
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
W/dalvikvm(16234): VFY: unable to find class referenced in signature (Ljava/awt/image/BufferedImage;)
D/dalvikvm(16234): GC_CONCURRENT freed 612K, 7% free 9380K/10028K, paused 3ms+4ms, total 35ms
看来我没有正确地链接库资源,而有关这些主题的文档看起来非常有限。
当将.jar和armeabi/_.库链接到ANE时,有什么想法或理解吗?
升级到最新的javacv源后更新的错误日志:
W/dalvikvm(14799): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/bytedeco/javacpp/avutil;
W/dalvikvm(14799): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lorg/bytedeco/javacpp/avformat;
W/dalvikvm(14799): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/bytedeco/javacpp/opencv_core;
发布于 2014-08-12 05:43:09
链接.so依赖项:
您应该确保您的文件夹结构正确。参见“这个链接”下的Android本机库部分。只需在“libs/ .so _platform/”文件夹中放置您的本机依赖项,就可以确保ADT将它们放在最终APK中的正确位置。
示例:YOUR_ANE_ROOT_FOLDER/android/libs/armeabi-v7a/libYourLibrary.so
如果您支持多个体系结构,那么您也可能有一个YOUR_ANE_ROOT_FOLDER/android/libs/armeabi/libYourLibrary.so
以此类推。
还要确保您的共享对象使用"lib“前缀命名。示例:libYourLibrary.so
链接JAR依赖项:
如果在platform.xml中"packagedDependencies“标记下指定jar依赖项不起作用,则可以尝试提取所有外部JAR并将它们包含在最后的jar中。
示例:
<javac source="1.6" srcdir="../android/src" destdir="../android/temp/classes" includeantruntime="false">
<classpath>
<pathelement location="${android.sdk}/android.jar"/>
<pathelement location="../android/libs/FlashRuntimeExtensions.jar"/>
<pathelement location="../android/libs/android-support-v4.jar"/>
<pathelement location="../android/libs/opencv.jar"/>
....
....
</classpath>
</javac>
<mkdir dir="../android/temp/zip"/>
<unzip src="../android/libs/opencv.jar" dest="../android/temp/zip"/>
<unzip src="../android/libs/android-support-v4.jar" dest="../android/temp/zip"/>
...
...
<copydir src="../android/temp/zip/com" dest="../android/temp/classes/com"/>
<copydir src="../android/temp/zip/android" dest="../android/temp/classes/android"/>
<mkdir dir="../temp/android/"/>
<copy todir="../temp/android/res/">
<fileset dir="../android/res"/>
</copy>
<jar destfile="../temp/android/lib${name}.jar">
<fileset dir="../android/temp/classes"/>
</jar>
<delete dir="../android/temp"/>
如果这些类仍然无法到达最终的APK,那么请看这!
https://stackoverflow.com/questions/25193851
复制相似问题