I am using this project as a reference : The code is avaiable at http://roman10.net/src/affmpeg.zip.
I am trying to compile this project with ffmpeg with different configuration than the project suggests.
I've compiled a new libffmpeg.so and added it to the project.
However, now i'm getting an "UnsatisfiedLinkError"
02-24 11:05:45.644: D/dalvikvm(11363): Trying to load lib /data/data/roman10.media.ffmpeg/lib/libffmpeg.so 0x47b0ec70
02-24 11:05:45.680: D/dalvikvm(11363): Added shared lib /data/data/roman10.media.ffmpeg/lib/libffmpeg.so 0x47b0ec70
02-24 11:05:45.680: D/dalvikvm(11363): No JNI_OnLoad found in /data/data/roman10.media.ffmpeg/lib/libffmpeg.so 0x47b0ec70, skipping init
02-24 11:05:45.684: D/dalvikvm(11363): Trying to load lib /data/data/roman10.media.ffmpeg/lib/libconverter.so 0x47b0ec70
02-24 11:05:45.687: I/dalvikvm(11363): Unable to dlopen(/data/data/roman10.media.ffmpeg/lib/libconverter.so): Cannot load library: link_image[1995]: failed to link libconverter.so
02-24 11:05:45.687: W/dalvikvm(11363): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lroman10/media/ffmpeg/ffmpegService;.<clinit>
02-24 11:05:45.687: W/dalvikvm(11363): Class init failed in newInstance call (Lroman10/media/ffmpeg/ffmpegService;)
02-24 11:05:45.687: D/AndroidRuntime(11363): Shutting down VM
02-24 11:05:45.687: W/dalvikvm(11363): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
02-24 11:05:45.695: E/AndroidRuntime(11363): FATAL EXCEPTION: main
02-24 11:05:45.695: E/AndroidRuntime(11363): java.lang.ExceptionInInitializerError
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.Class.newInstanceImpl(Native Method)
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.Class.newInstance(Class.java:1429)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2940)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.app.ActivityThread.access$3300(ActivityThread.java:125)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.os.Looper.loop(Looper.java:123)
02-24 11:05:45.695: E/AndroidRuntime(11363): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.reflect.Method.invoke(Method.java:521)
02-24 11:05:45.695: E/AndroidRuntime(11363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
02-24 11:05:45.695: E/AndroidRuntime(11363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
02-24 11:05:45.695: E/AndroidRuntime(11363): at dalvik.system.NativeStart.main(Native Method)
02-24 11:05:45.695: E/AndroidRuntime(11363): Caused by: java.lang.UnsatisfiedLinkError: Library converter not found
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.Runtime.loadLibrary(Runtime.java:461)
02-24 11:05:45.695: E/AndroidRuntime(11363): at java.lang.System.loadLibrary(System.java:557)
02-24 11:05:45.695: E/AndroidRuntime(11363): at roman10.media.ffmpeg.ffmpegService.<clinit>(ffmpegService.java:123)
I decided to recompile the converter.so file
however, when running the ndk-build command on it, i receive these messages:
c:\Users\user\workspace\Main\jni>c:\work\android-ndk-r8d\ndk-build
c:/android-ndk-r8d/build/core/build-binary.mk:266: warning: overriding comm
ands for target `c:/Users/user/workspace/Main//obj/local/armeabi/objs/converter'
c:/android-ndk-r8d/build/core/build-binary.mk:266: warning: ignoring old co
mmands for target `c:/Users/user/workspace/Main//obj/local/armeabi/objs/converte
r'
c:/android-ndk-r8d/build/core/build-binary.mk:266: warning: overriding comm
ands for target `c:/Users/user/workspace/Main//obj/local/armeabi/objs/converter'
c:/android-ndk-r8d/build/core/build-binary.mk:266: warning: ignoring old co
mmands for target `c:/Users/user/workspace/Main//obj/local/armeabi/objs/converte
r'
c:/android-ndk-r8d/build/core/build-binary.mk:357: warning: overriding comm
ands for target `c:/Users/user/workspace/Main//obj/local/armeabi'
c:/android-ndk-r8d/build/core/build-binary.mk:357: warning: ignoring old co
mmands for target `c:/Users/user/workspace/Main//obj/local/armeabi'
c:/android-ndk-r8d/build/core/build-binary.mk:439: warning: overriding comm
ands for target `c:/Users/user/workspace/Main//libs/armeabi'
c:/android-ndk-r8d/build/core/build-binary.mk:439: warning: ignoring old co
mmands for target `c:/Users/user/workspace/Main//libs/armeabi'
c:/android-ndk-r8d/build/core/build-binary.mk:357: warning: overriding comm
ands for target `c:/Users/user/workspace/Main//obj/local/armeabi'
c:/android-ndk-r8d/build/core/build-binary.mk:357: warning: ignoring old co
mmands for target `c:/Users/user/workspace/Main//obj/local/armeabi'
"Compile thumb : converter <= cmdutils.c
c:/Users/user/workspace/Main//jni/cmdutils.c:32:34: fatal error: libavformat/avf
ormat.h: No such file or directory
compilation terminated.
make: *** [c:/Users/user/workspace/Main//obj/local/armeabi/objs/converter/cmduti
ls.o] Error 1
What can I do to fix this, and make it work?
According to the error you are missing the libavformat headers.
I found this:
FFMpeg on Android, undefined references to libavcodec functions, although it is listed on command line
Related
My app uses custom contentView and contentBigView. Essentially it supports expanding notifications. I have a bug that causes the app to crash and it is only happens on a few devices. I can not reproduce this issue myself however this issue is persistent on the listed devices below.
I can see this is only happening on Android 4.2.x. Anyone have any ideas of a potential bug on Android?
Devices
THL T100S [Android 4.2.2]
Lenovo P780 (P780_ROW) [Android 4.2.1]
Lenovo S820 (S820_ROW) [Android 4.2]
Lenovo A766 [Android 4.2]
Logcat
02-24 09:45:39.752 E/AndroidRuntime( 4281): FATAL EXCEPTION: main
02-24 09:45:39.752 E/AndroidRuntime( 4281): android.app.RemoteServiceException: Bad notification posted from package com.android.DroidLiveLite: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.android.DroidLiveLite id=2131165283 tag=null score=0 notn=Notification(pri=0 contentView=com.android.DroidLiveLite/0x7f03004d vibrate=null sound=null defaults=0x0 flags=0x62 kind=[null]) user=UserHandle{0})
02-24 09:45:39.752 E/AndroidRuntime( 4281): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at android.os.Handler.dispatchMessage(Handler.java:107)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at android.os.Looper.loop(Looper.java:194)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at android.app.ActivityThread.main(ActivityThread.java:5405)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at java.lang.reflect.Method.invoke(Method.java:525)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
02-24 09:45:39.752 E/AndroidRuntime( 4281): at dalvik.system.NativeStart.main(Native Method)
I'm trying to process camera image on opencv(2.4.8) and record video together on android.
In the middle of just camera preview, video record is done successfully, however, after starting
image process on opencv, there is EXCEPTION like below. It is not functional videowriter API in opnecv on android, so I used MediaRecorder that is android API to record video.
Is there any way I can solve the problems were occurred by when trying to process image and video record at the same time?
Thanks!
02-24 16:38:50.071: E/AndroidRuntime(8117): FATAL EXCEPTION: main
02-24 16:38:50.071: E/AndroidRuntime(8117): java.lang.RuntimeException: Method called after release()
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.setHasPreviewCallback(Native Method)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.access$600(Camera.java:133)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:815)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Looper.loop(Looper.java:137)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.app.ActivityThread.main(ActivityThread.java:4961)
02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
02-24 16:38:50.071: E/AndroidRuntime(8117): at dalvik.system.NativeStart.main(Native Method)
Decided to use Scandit SDK to get the barcode scanning feature in my app. Unfortunately, since I'm relatively new to Android development and Java in general I've run into a few issues that I can't seem to work out. The demo that Scandit provided doesn't give any errors(runs fine) but crashes when I try to start it up (pressing a button from one activity is meant to start it up). I've tried reading the logcat and googling a solution to the problems but I'm not getting the right solutions. Does anyone have an idea of what I'm doing wrong?
Logcat is provided below:
10-08 23:30:00.807 21563-21563/com.kwesimbia.management D/AndroidRuntime? Shutting down VM
10-08 23:30:00.807 21563-21563/com.kwesimbia.management W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x40aa4228)
10-08 23:30:00.817 21563-21563/com.kwesimbia.management E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3082)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.kwesimbia.management.ScanditSDKDemoSimple
at com.kwesimbia.management.Activity_D.initiateCodeScan(Activity_D.java:63)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3077)
at android.view.View.performClick(View.java:3549)
at android.view.View$PerformClick.run(View.java:14393)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:4944)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Process: com.kwesimbia.management
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger? App crashed!
Package: com.kwesimbia.management v1 (1.0)
10-08 23:30:00.817 32726-587/? E/EmbeddedLogger?
Application Label: firstapp
10-08 23:30:00.827 32726-587/? W/ActivityManager?
Force finishing activity com.kwesimbia.management/.Activity_D
I came across this problem as well, my solution was to extract the library files and put them as their files in the lib folder
The library basically isn't being exported with it
EDIT
So I checked out my project, basically I did these things:
In the libs folder I have a new folder called armeabi and inside that I have libscanditsdk-android-3.3.1.so
Then in my build path I have also referenced the jar file that they provide:
<classpathentry exported="true" kind="lib" path="C:/GIT/Android/FwayScannerProject/FwayScanner/libs/scanditsdk-barcodepicker-android-3.3.1.jar"/>
I am trying to load prebuild native shared library from MainActivity of my project in following way:
static
{
System.loadLibrary("mylib.so"); // I have tried this way
//System.loadLibrary("libmylib.so"); // Also tried this way
//System.loadLibrary("mylib"); // Also tried this way
}
But all times it throws following exception:
Warning before exception:
07-12 11:08:36.019: W/dalvikvm(21552): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/libtest/src/MainActivity;
07-12 11:08:42.790: W/dalvikvm(21552): Class init failed in newInstance call (Lcom/libtest/src/MainActivity;)
07-12 11:08:47.067: D/AndroidRuntime(21552): Shutting down VM
07-12 11:08:47.067: W/dalvikvm(21552): threadid=1: thread exiting with uncaught exception (group=0x40015560)
Then exception:
07-12 11:08:47.167: E/AndroidRuntime(21552): FATAL EXCEPTION: main
07-12 11:08:47.167: E/AndroidRuntime(21552): java.lang.ExceptionInInitializerError
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstanceImpl(Native Method)
07-12 11:08:47.167: E/AndroidRuntime(21552): at java.lang.Class.newInstance(Class.java:1409)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 11:08:47.167: E/AndroidRuntime(21552): at android.os.Looper.loop(Looper.java:130)
Native shared library placed "libs\armeabi\mylib.so" under my project folder.
Please help me what I did wrong?
your library name should be
libmylib.so
You should change the settings of the project which is generating the library and generate with correct name. then you can load this library using
System.loadLibrary("mylib");
As a quick measure, you can just rename the library name and try.
According to this document It Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.
check somewhere you tried static initialization
I have a problem running tutorial2 (Advanced - Mix java 9+ native
opencv) sample on HTC incredible S.
Other samples work great.
The app terminates immediately with this message: "The application
Tutorial 2 Advanced - 2. Mix Java + Native OpenCV( process
org.opencv.samples.tutorial4) has expired unexpectedly. Please try
again."
Any help or suggestion?
02-24 22:27:12.083: I/Process(2212): Sending signal. PID: 2212 SIG: 9
02-24 23:15:34.915: I/Sample::Activity(2296): Instantiated new class
org.opencv.samples.tutorial4.Sample4Mixed
02-24 23:15:34.935: I/Sample::Activity(2296): onCreate
02-24 23:15:34.935: W/dalvikvm(2296): Exception Ljava/lang/
UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/
tutorial4/Sample4View;
02-24 23:15:34.935: D/AndroidRuntime(2296): Shutting down VM
02-24 23:15:34.935: W/dalvikvm(2296): threadid=1: thread exiting with
uncaught exception (group=0x4001d5a0)
02-24 23:15:34.945: E/AndroidRuntime(2296): FATAL EXCEPTION: main
02-24 23:15:34.945: E/AndroidRuntime(2296):
java.lang.ExceptionInInitializerError
02-24 23:15:34.945: E/AndroidRuntime(2296): at
org.opencv.samples.tutorial4.Sample4Mixed.onCreate(Sample4Mixed.java:
35)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1072)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1785)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1842)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.access$1500(ActivityThread.java:132)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.os.Handler.dispatchMessage(Handler.java:99)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.os.Looper.loop(Looper.java:150)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.main(ActivityThread.java:4263)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.reflect.Method.invokeNative(Native Method)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.reflect.Method.invoke(Method.java:507)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
dalvik.system.NativeStart.main(Native Method)
02-24 23:15:34.945: E/AndroidRuntime(2296): Caused by:
java.lang.UnsatisfiedLinkError: Couldn't load mixed_sample:
findLibrary returned null
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.Runtime.loadLibrary(Runtime.java:429)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.System.loadLibrary(System.java:554)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
org.opencv.samples.tutorial4.Sample4View.<clinit>(Sample4View.java:91)
02-24 23:15:34.945: E/AndroidRuntime(2296): ... 14 more
02-24 23:20:35.008: I/Process(2296): Sending signal. PID: 2296 SIG: 9
seems like a linking error due to
02-24 23:15:34.935: W/dalvikvm(2296): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial4/Sample4View;
check your project settings for the toolchain for the build settings.
this might bring you more information:
http://opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.html