7

Could someone tell me where I'm doing wrong? These are the steps that I have followed:

  1. Downloaded the adt-bundle-windows from android developer website

  2. Created a new project and a libs/armeabi folder

  3. Extract all the *.so files from javacv-android-arm.jar, opencv-2.4.3-android-arm.zip, and ffmpeg-1.0-android-arm.zip directly into the newly created "libs/armeabi" folder, without creating any new subdirectories.

    (A part that I don't understand is "Extract all the *.so files from javacv-android-arm.jar", I simply inserted the javacv-android-arm.jar file inside libs/armeabi folder)

  4. Navigated to Project > Properties > Java Build Path > Libraries and click "Add JARs...".

  5. Selected both javacpp.jar and javacv.jar from the newly created "libs" folder.

After that I have downloaded OpenCV2.4.3 from here and ffmpeg from here and extracted the files on my C:/ root. Finally after setting my system path...,

C:\opencv\build\x64\vc10\bin;C:\ffmpeg-64\bin;C:\Program Files\Java\jdk1.7.0_10\bin

...if I try to use simply FrameGrabber in my Android application...

import com.googlecode.javacv.FFmpegFrameGrabber;
import com.googlecode.javacpp.Loader;
import com.googlecode.javacv.*;
import com.googlecode.javacv.cpp.*;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_calib3d.*;
import static com.googlecode.javacv.cpp.opencv_objdetect.*;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        FFmpegFrameGrabber i = new FFmpegFrameGrabber("/mnt/sdcard/SinglePerson.avi"); 
    }

...I get the following errors:

01-29 17:59:26.976: E/AndroidRuntime(30656): FATAL EXCEPTION: main
01-29 17:59:26.976: E/AndroidRuntime(30656): java.lang.NoClassDefFoundError: com.googlecode.javacv.FFmpegFrameGrabber
01-29 17:59:26.976: E/AndroidRuntime(30656):    at com.example.xxxxxxxxx.MainActivity.onCreate(MainActivity.java:23)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.Activity.performCreate(Activity.java:4465)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.os.Looper.loop(Looper.java:137)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at android.app.ActivityThread.main(ActivityThread.java:4424)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at java.lang.reflect.Method.invokeNative(Native Method)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at java.lang.reflect.Method.invoke(Method.java:511)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-29 17:59:26.976: E/AndroidRuntime(30656):    at dalvik.system.NativeStart.main(Native Method)

Someone can help me please?

Community
  • 1
  • 1
Mark
  • 346
  • 2
  • 5
  • 18

5 Answers5

12

So a jar file is basically a zip file, if you change the extension to ".zip" you can extract the files it contains like you did with OpenCV and FFMPEG.

So, rename "javacv-android-arm.jar" to " javacv-android-arm.zip," extract the .so files out of it and copy them to libs/armeabi.

Good luck!

Mark W
  • 213
  • 1
  • 9
  • Thanks for your suggestion, I tried to include also the other .so files but the problem remains. – Mark Jan 29 '13 at 21:26
  • 2
    Ok Ok I solved... the problem was that I inserted the jar file inside libs/armeabi instead of libs. X-( – Mark Jan 30 '13 at 10:24
2

Gradle:

compile 'org.bytedeco:javacv:1.0' compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-x86' compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-x86' compile 'org.bytedeco.javacpp-presets:opencv:2.4.11-0.11:android-arm' compile 'org.bytedeco.javacpp-presets:ffmpeg:2.6.1-0.11:android-arm'

this will integrate javacv to android

Muhammad Umair Shafique
  • 2,475
  • 1
  • 30
  • 39
0

Use this example:

http://javacv4android.blogspot.com.br/2014/02/how-to-import-javacv-libraries-to.html

later in OnCreate:

try {
        FrameGrabber grabber2 = new FFmpegFrameGrabber(Environment
                .getExternalStorageDirectory().getAbsolutePath()
                + "/TESTE/spell.mp3");

        String t = "!";

        grabber2 = null;

    } catch (Exception e) {
        e.printStackTrace();
    }

if don't exist error, it's ok =)

Sorry for my english

Elton da Costa
  • 1,279
  • 16
  • 27
0

For latest version. In build.gradle:

repositories {
...
   mavenCentral()
}
dependencies {
...
   compile group: 'org.bytedeco', name: 'javacv', version: '1.2'
   compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version:   '3.1.0-1.2', classifier: 'android-arm'
   compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version:   '3.1.2-1.2', classifier: 'android-arm'
}
configurations {
   all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}
Ruslan Berozov
  • 540
  • 7
  • 16
0

For anyone who come last.

in the build gradle **(module:app)

add this code on it.

    dependencies {
    implementation group: 'org.bytedeco', name: 'javacv-platform', version: '1.5.8'
}
DevGold
  • 39
  • 1
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 22 '23 at 00:53