Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsatisfiedLinkError: org.bytedeco.javacpp.avutil #8

Closed
JoyHong opened this issue Oct 26, 2016 · 22 comments
Closed

UnsatisfiedLinkError: org.bytedeco.javacpp.avutil #8

JoyHong opened this issue Oct 26, 2016 · 22 comments

Comments

@JoyHong
Copy link

JoyHong commented Oct 26, 2016

Dear

Now, i'm using latest code, but in some platform(eg. Meizu 6.0+), it crash with following message.
I don't know how to handle it...

Caused by: 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:474)
at org.bytedeco.javacpp.Loader.load(Loader.java:419)
at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1559)
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:149)
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:129)

@CrazyOrr
Copy link
Owner

Will this error occur on those platforms if you set targetSdkVersion to 22?

@JoyHong
Copy link
Author

JoyHong commented Oct 27, 2016

Yes, when i set targetSdkVersion to 22, this issue still occur.

@CrazyOrr
Copy link
Owner

Check out this and this.
P.S. You can use this tool to see if those .so libraries are available on your device.

@JoyHong
Copy link
Author

JoyHong commented Oct 28, 2016

Dear
I checked with the tool
In the devices work well, it supprot arm64-v8a, armeabi-v7a, armeabi.
In the devices occur crash, it only support armeabi-v7a, armeabi.
Could u please help to support it for me?

@CrazyOrr
Copy link
Owner

I'll look into it, but I don't think arm64-v8a is the problem here. Because on my Nexus 6, which only supports armeabi-v7a and armeabi, this error doesn't occur.

@hexmonad
Copy link

Hi @JoyHong ,
did you try a manual installation: https://github.com/bytedeco/javacv#manual-installation ?
This is done in this commit: 2ab86b6
Please check it out.

@JoyHong
Copy link
Author

JoyHong commented Oct 28, 2016

btw, does following configuration will effect the result?
ndk {
abiFilters 'armeabi'
}

@hexmonad
Copy link

Yes, it does. From https://developer.android.com/studio/projects/add-native-code.html:

By default, Gradle builds your native library into separate .so files for the ABIs the NDK supports and packages them all into your APK. If you want Gradle to build and package only certain ABI configurations of your native libraries, you can specify them with the ndk.abiFilters flag in your module-level build.gradle file

So, if you use "abiFilters 'armeabi'", you should place .so files in the app/src/main/jniLibs/armeabi folder.

@CrazyOrr
Copy link
Owner

I don't think so because there are only armeabi libraries, so you don't need to specify that.

@hexmonad
Copy link

When you use the tool mentioned here: #8 (comment),
do you see libraries under Native Libraries Installed section, like libavutil.so etc. ?

@JoyHong
Copy link
Author

JoyHong commented Oct 28, 2016

Yes, I saw them
but, I check the list is the same with my two devices.

@tingfengainiaini
Copy link

tingfengainiaini commented Nov 1, 2016

@JoyHong
Copy link
Author

JoyHong commented Nov 1, 2016

Dear, help me, sorry for my poor knowledge.
Now i got aother crash log, Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacpp/avutil
I follow the doc to manully in manual-installation, but i can't find any jar files in the javacpp-presets-1.2-bin or javacpp-presets-1.2-src, should i need to compile them?

@CrazyOrr
Copy link
Owner

CrazyOrr commented Nov 1, 2016

You should download javacv-1.2-bin.zip, and unzip xx-android-arm/x86.jar in it to get .so files.

@JoyHong
Copy link
Author

JoyHong commented Nov 1, 2016

Hi
Should i add ffmpeg-android-arm.jar and opencv-android-arm.jar to libs
and remove following configuations?

configurations {
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}
compile group: 'org.bytedeco', name: 'javacpp', version: '1.2.4'
compile(group: 'org.bytedeco', name: 'javacv', version: '1.2') {
exclude group: 'org.bytedeco.javacpp-presets'
}
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.0.2-1.2'
compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.0.2-1.2', classifier: 'android-arm'

@CrazyOrr
Copy link
Owner

CrazyOrr commented Nov 1, 2016

No, ffmpeg-android-arm.jar = compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '3.0.2-1.2', classifier: 'android-arm', and opencv-android-arm.jar is not needed.
You need to put javacpp.jar, javacv.jar, ffmpeg.jar, ffmpeg-android-arm.jar in libs.

@JoyHong
Copy link
Author

JoyHong commented Nov 2, 2016

Dear CrazyOrr
It still not work in some devices.
but, i found that these devices are 32bit, i suppose it's the key point.
How can i specify use 32bit so?

@JoyHong
Copy link
Author

JoyHong commented Nov 2, 2016

I install your project to 32bit device, the same crash will occurs
Process: com.github.crazyorr.ffmpegrecorder, PID: 26874
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
at org.bytedeco.javacpp.Loader.load(Loader.java:479)
at org.bytedeco.javacpp.Loader.load(Loader.java:419)
at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1559)
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:149)
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:129)
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.initRecorder(FFmpegRecordActivity.java:417)
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.access$1100(FFmpegRecordActivity.java:51)
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:287)
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:282)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at org.bytedeco.javacpp.Loader.load(Loader.java:474)
at org.bytedeco.javacpp.Loader.load(Loader.java:419) 
at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1559) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:149) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:129) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.initRecorder(FFmpegRecordActivity.java:417) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.access$1100(FFmpegRecordActivity.java:51) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:287) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:282) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacpp/avutil
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:251) 
at org.bytedeco.javacpp.Loader.load(Loader.java:474) 
at org.bytedeco.javacpp.Loader.load(Loader.java:419) 
at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1559) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:149) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:129) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.initRecorder(FFmpegRecordActivity.java:417) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.access$1100(FFmpegRecordActivity.java:51) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:287) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:282) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.bytedeco.javacpp.avutil" on path: DexPathList[[zip file "/data/app/com.github.crazyorr.ffmpegrecorder-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.github.crazyorr.ffmpegrecorder-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:251) 
at org.bytedeco.javacpp.Loader.load(Loader.java:474) 
at org.bytedeco.javacpp.Loader.load(Loader.java:419) 
at org.bytedeco.javacpp.avcodec$AVPacket.(avcodec.java:1559) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:149) 
at org.bytedeco.javacv.FFmpegFrameRecorder.(FFmpegFrameRecorder.java:129) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.initRecorder(FFmpegRecordActivity.java:417) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity.access$1100(FFmpegRecordActivity.java:51) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:287) 
at com.github.crazyorr.ffmpegrecorder.FFmpegRecordActivity$5.doInBackground(FFmpegRecordActivity.java:282) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 

@JoyHong
Copy link
Author

JoyHong commented Nov 2, 2016

Could u please help to solve it asap?

@JoyHong
Copy link
Author

JoyHong commented Nov 2, 2016

Sorry, correct, it not depends 32bit
Meizu 64bit still occurs this crash.....

@tingfengainiaini
Copy link

tingfengainiaini commented Nov 21, 2016

@JoyHong
I have encoutered this today again in Meizu note 3, with javacv1.2. javacpp1.2.4, javacpp presets 1.2.
I used javacv in a sub module of my project, not app module. This time, the relinker did no help.
When I move the relinker function into main ui thread, mainactivity's onCreate for example. It works!
But I have not test other phones yet.
Add these codes in your main ui thread (add relinker in your gradle first). Hope this works for you.

        ReLinker.log(logger).recursively().loadLibrary(this, "avdevice");
        ReLinker.log(logger).recursively().loadLibrary(this, "avfilter");
        ReLinker.log(logger).recursively().loadLibrary(this, "avformat");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniavutil");
        ReLinker.log(logger).recursively().loadLibrary(this, "avutil");
        ReLinker.log(logger).recursively().loadLibrary(this, "postproc");
        ReLinker.log(logger).recursively().loadLibrary(this, "swscale");
        ReLinker.log(logger).recursively().loadLibrary(this, "swresample");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniavdevice");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniavfilter");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniavformat");
        ReLinker.log(logger).recursively().loadLibrary(this, "jnipostproc");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniswresample");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniswscale");
        ReLinker.log(logger).recursively().loadLibrary(this, "jniavcodec");
        ReLinker.log(logger).recursively().loadLibrary(this, "avcodec");

Add: (2016/11/25)
You should clean your project when updating the native library, if you use AS! Remeber!

@JoyHong
Copy link
Author

JoyHong commented Nov 28, 2016

Dear tingfengainiaini
It works, many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants