Air ANE - 链接原生的库

时间:2014-08-07 23:26:26

标签: android actionscript-3 air javacv ane

我试图在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;

1 个答案:

答案 0 :(得分:1)

关联.so依赖关系:

您应确保文件夹结构正确无误。请参阅 Android原生库部分下的"This link"。只需将.so本机依赖项放在" libs / target_platform /"文件夹确保ADT将它们放在最终APK内的正确位置。

示例: YOUR_ANE_ROOT_FOLDER / android / libs / armeabi-v7a / libYourLibrary.so

如果你支持多种架构,你可能也会有 YOUR_ANE_ROOT_FOLDER /机器人/库/的 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,请参阅THIS