一起使用JavaCV和Realm会导致"java.lang.UnsatisfiedLinkError". [英] Using JavaCV and Realm together causes "java.lang.UnsatisfiedLinkError"
问题描述
我最近通过尝试启动JavaCV的FFmpegFrameGrabber实例而出现以下错误:
I have recently been getting the following error by attempting to start an instance of JavaCV's FFmpegFrameGrabber:
java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avformat$AVFormatContext.<clinit>(avformat.java:2597)
at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:386)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:380)...
虽然存在解决此问题的方法,但没有一个对我有用.
While solutions to this problem exist, none worked for me.
通过许多试验,我发现足够奇怪的是,如果我不将Realm包含在我的项目中,那么我将不再收到此错误.
Through many trials i have discovered that weirdly enough, if i do not include Realm in my project, i no longer receive this error.
这是我的build.gradle文件的一部分,其中包含所有这些库:
Here is the part of my build.gradle file in which I include all of these libraries:
compile group: 'org.bytedeco', name: 'javacv', version: '1.1'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '3.0.0-1.1', classifier: 'android-x86'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.8.1-1.1', classifier: 'android-x86'
// ORM
compile 'io.realm:realm-android:0.87.2' // Tested NOT OK - Causes JavaCV to crash
//
我认为可能有一个我不知道的解决方案.我在互联网上的任何地方都没有提到图书馆不兼容,也没有提到为什么会发生这种现象.
I am thinking that there may be a solution to this problem that i am not aware of. I found no mention anywhere on the internet about library incompatibility or why this behaviour may occur.
我将用任何其他人可能需要的其他详细信息来编辑此帖子.
I will edit this post with any additional details that anyone might need.
任何帮助将不胜感激.
编辑
我试图应用此处所述的修复程序. 现在,我的包装选项如下:
I attempted to apply the fix described here. Now my packaging options look like this:
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
exclude "lib/arm64-v8a/librealm-jni.so"
}
不幸的是,此更改无效.我仍然被困住.
Unfortunately, this change has no effect. I'm still stuck.
推荐答案
在我的一位同事的帮助下,我已经能够解决此问题.
With the help of one of my coleagues i have been able to solve this issue.
除问题中描述的步骤外,我们:
In adition to the steps described in the question, we:
- 复制 app/src/main/jniLibs/armeabi 和 app/src/main/jniLibs/armeabi-v7a 文件夹中的所有.so文件
-
已添加
- Copyed all of the .so files in the app/src/main/jniLibs/armeabi and app/src/main/jniLibs/armeabi-v7a folders
Added
ndk { abiFilters"armeabi-v7a" }
ndk { abiFilters "armeabi-v7a" }
到模块的 build.gradle 文件的 defaultConfig 部分
已添加
lintOptions { abortOnError假 }
lintOptions { abortOnError false }
到模块的 build.gradle 文件的 android 部分
如果我有能力,我将尝试向需要它们的任何人提供进一步的说明.
I will try to provide further clarifications to anyone that needs them if i am able.
这篇关于一起使用JavaCV和Realm会导致"java.lang.UnsatisfiedLinkError".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!