gpt4 book ai didi

android - Air ANE - 链接原生 so 库

转载 作者:行者123 更新时间:2023-11-30 02:45:03 25 4
gpt4 key购买 nike

我正在尝试在 AIR 项目中使用 JavaCV。我构建了一个 native 扩展并且它编译得很好但是在运行时我收到以下错误:

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;

最佳答案

链接 .so 依赖项:

您应该确保您的文件夹结构是正确的。参见 "This link"Android native 库部分 下。只需将 .so native 依赖项放在“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,请参阅 THIS !

关于android - Air ANE - 链接原生 so 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25193851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com