我正在尝试制作一个实时流媒体应用程序,并且我已按照以下链接将 javacv 添加到我的项目 https://github.com/bytedeco/javacv中。我在我的应用程序(app->src->main)中创建了 jniLibs 文件夹,但我的应用程序崩溃而没有任何错误。当我尝试调试时,我发现代码在 FFmpegFrameRecorder.class 的这一行中断
public static void tryLoad() throws Exception {
if(loadingException != null) {
throw loadingException;
} else {
try {
Loader.load(avutil.class); // exception here
Loader.load(swresample.class);
Loader.load(avcodec.class);
Loader.load(avformat.class);
Loader.load(swscale.class);
avformat.av_register_all();
avformat.avformat_network_init();
} catch (Throwable var1) {
if(var1 instanceof Exception) {
throw loadingException = (Exception)var1;
} else {
throw loadingException = new Exception("Failed to load " + FFmpegFrameRecorder.class, var1);
}
}
}
}
我不知道如何解决这个错误。请帮我解决这个问题。提前致谢
编辑这是堆栈跟踪:
10-06 10:14:56.242 15946-15946/triptam.go.testopencv E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
at org.bytedeco.javacpp.Loader.load(Loader.java:392)
at org.bytedeco.javacpp.Loader.load(Loader.java:358)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1407)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at triptam.go.testopencv.MainActivity.initRecorder(MainActivity.java:411)
at triptam.go.testopencv.MainActivity.access$1000(MainActivity.java:85)
at triptam.go.testopencv.MainActivity$startInit$1.run(MainActivity.java:780)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5410)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:390)
at org.bytedeco.javacpp.Loader.load(Loader.java:358)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1407)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at triptam.go.testopencv.MainActivity.initRecorder(MainActivity.java:411)
at triptam.go.testopencv.MainActivity.access$1000(MainActivity.java:85)
at triptam.go.testopencv.MainActivity$startInit$1.run(MainActivity.java:780)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5410)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacpp/avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:390)
at org.bytedeco.javacpp.Loader.load(Loader.java:358)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1407)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at triptam.go.testopencv.MainActivity.initRecorder(MainActivity.java:411)
at triptam.go.testopencv.MainActivity.access$1000(MainActivity.java:85)
at triptam.go.testopencv.MainActivity$startInit$1.run(MainActivity.java:780)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5410)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.bytedeco.javacpp.avutil" on path: DexPathList[[zip file "/data/app/triptam.go.testopencv-2.apk", zip file "/data/data/triptam.go.testopencv/code_cache/secondary-dexes/triptam.go.testopencv-2.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/triptam.go.testopencv-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:217)
at org.bytedeco.javacpp.Loader.load(Loader.java:390)
at org.bytedeco.javacpp.Loader.load(Loader.java:358)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1407)
at org.bytedeco.javacv.FFmpegFrameRecorder.<init>(FFmpegFrameRecorder.java:149)
at triptam.go.testopencv.MainActivity.initRecorder(MainActivity.java:411)
at triptam.go.testopencv.MainActivity.access$1000(MainActivity.java:85)
at triptam.go.testopencv.MainActivity$startInit$1.run(MainActivity.java:780)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5410)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
这是我的 build.gradle :
compile group: 'org.bytedeco', name: 'javacv', version: '1.0'
compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.9-1.0', classifier: 'android-arm'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.3-1.0', classifier: 'android-arm'