JavaCV configuration in Android Studio

我怕爱的太早我们不能终老 提交于 2020-01-22 12:40:08

问题


I know there is a lot of similiar questions to this, but a lot of them seem to be out of date because of the development of libraries such JavaCV.

I used the code from Video Creation with Images and Audio in Android to create movie, but I have a problem with lib imports.

I did as JavaCV page says, I put dependency in gradle :

compile group: 'org.bytedeco', name: 'javacv', version: '0.9'

now, I don't know if I have to do something else?

I have used these imports :

import org.bytedeco.javacpp.avcodec;
import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacv.FFmpegFrameRecorder;

import static org.bytedeco.javacpp.opencv_highgui.cvLoadImage;

and get this error :

Caused by: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
        at org.bytedeco.javacpp.Loader.load(Loader.java:387)
        at org.bytedeco.javacpp.Loader.load(Loader.java:353)
        at org.bytedeco.javacpp.avformat.<clinit>(avformat.java:13)
        at org.bytedeco.javacv.FFmpegFrameRecorder.<clinit>(FFmpegFrameRecorder.java:106)
        at voidstudio.app.activity.CreateMovieTask.doInBackground(CreateMovieTask.java:46)
        at voidstudio.app.activity.CreateMovieTask.doInBackground(CreateMovieTask.java:21)

and

Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:217)

and

 Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jniavutil from loader dalvik.system.PathClassLoader[dexPath=/data/app/voidstudio.app-1.apk,libraryPath=/data/app-lib/voidstudio.app-1]: findLibrary returned null
        at java.lang.Runtime.loadLibrary(Runtime.java:365)
        at java.lang.System.loadLibrary(System.java:521)
        at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
        at org.bytedeco.javacpp.Loader.load(Loader.java:410)

did I missed sth in configuration? I have seen similiar questions but there was no proper answer for this.


回答1:


Update! I've also found out that if you have have an armeabi-v7a folder in the jniLibs, or are using anything other than an armeabi folder, you will have issues with the .so files not being added.

Looks like ffmpeg is not being imported. I had the same problem. Here is what I did. Let me know if this helps you!

compile group: 'org.bytedeco', name: 'javacv', version: '0.9'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.9-0.9', classifier:    'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.3-0.9', classifier: 'android-arm'



回答2:


Check the placement of jniLibs folder

I have just changed the placement of my jniLibs (before it was outside main folder) and this worked for me, please check the image! hope this will help



来源:https://stackoverflow.com/questions/25660828/javacv-configuration-in-android-studio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!