6

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.

filipp.kowalski
  • 5,495
  • 7
  • 27
  • 45

2 Answers2

8

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'
tylerjroach
  • 2,699
  • 4
  • 19
  • 24
  • I'm not very familiar with gradle dependencies but from where do you get versions for ffmpeg and opencv (version: '2.4.9-0.9', version: '2.3-0.9') – Vadym Feb 03 '15 at 22:32
  • I just looked on MavenCentral. Here is a link to the FFMPEG one. It looks like there is a new version that was released in December. http://mvnrepository.com/artifact/org.bytedeco.javacpp-presets/ffmpeg – tylerjroach Feb 04 '15 at 20:48
  • I'm using version 0.11 of javacv and replaced 'opencv' and 'ffmpeg' with the latest version i found in maven central. But still does not work. I do have a folder armeabi-v7a under my src/main which contains other .so files. Do I have to do anything about the armeabi-v7a folder? – Chris.Zou Apr 27 '15 at 07:22
  • I was unable to use gradle and had to manually import everything as a library. This way, I could move all of the armeabi files that javacv uses armeabi-v7a. – tylerjroach May 27 '15 at 18:27
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

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
Yourange
  • 158
  • 10