1

我正在尝试在 AIR 项目上使用 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/ _ .so 库链接到 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;
4

1 回答 1

1

链接 .so 依赖项:

您应该确保您的文件夹结构正确。请参阅Android 本机库部分下的“此链接”。只需将 .so 本机依赖项放入“libs/target_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 依赖项:

如果在“packagedDependencies”标签下的 platform.xml 中指定 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,那么请看这个

于 2014-08-12T13:43:09.323 回答