11

I have a video trimmer application code .

Its Android.mk file code is mentioned below:

MY_LOCAL_PATH := $(call my-dir)

include $(all-subdir-makefiles)

LOCAL_PATH :=$(MY_LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE    := video-trimmer
LOCAL_SRC_FILES := video-trimmer.c
LOCAL_C_INCLUDES := $(MY_LOCAL_PATH) $(MY_LOCAL_PATH)/ffmpeg
LOCAL_SHARED_LIBRARIES := ffmpeg 
LOCAL_LDLIBS += -lz -llog
include $(BUILD_SHARED_LIBRARY)

and Application.mk file code is :

APP_MODULES      := ffmpeg video-trimmer
APP_OPTIM := debug

When I try to run this application, I get following error :

02-26 16:06:05.779: E/AndroidRuntime(4092): FATAL EXCEPTION: main
02-26 16:06:05.779: E/AndroidRuntime(4092): Process: net.video.trimmer, PID: 4092
02-26 16:06:05.779: E/AndroidRuntime(4092): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "signal" referenced by "libffmpeg.so"...
02-26 16:06:05.779: E/AndroidRuntime(4092):     at java.lang.Runtime.loadLibrary(Runtime.java:364)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at java.lang.System.loadLibrary(System.java:526)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at net.video.trimmer.service.VideoTrimmingService.onCreate(VideoTrimmingService.java:29)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:2585)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.app.ActivityThread.access$1800(ActivityThread.java:139)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.os.Handler.dispatchMessage(Handler.java:102)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.os.Looper.loop(Looper.java:136)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at android.app.ActivityThread.main(ActivityThread.java:5086)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at java.lang.reflect.Method.invokeNative(Native Method)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at java.lang.reflect.Method.invoke(Method.java:515)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
02-26 16:06:05.779: E/AndroidRuntime(4092):     at dalvik.system.NativeStart.main(Native Method)

My video-trimmer.so and ffmpeg.so are generated in \libs\armeabi .

Thanks in advance.

Gaganpreet Singh
  • 886
  • 1
  • 9
  • 20
  • this link would help you:- http://stackoverflow.com/questions/18111739/why-do-some-android-phones-cause-our-app-to-throw-an-java-lang-unsatisfiedlinker – japanjot singh Feb 26 '15 at 11:00
  • @japanjotsingh Thanks . I appreciate your quick response – Gaganpreet Singh Feb 26 '15 at 11:08
  • can you try setting up `APP_PLATFORM:=android-15` inside your *Application.mk* ? – ph0b Feb 26 '15 at 14:58
  • @ph0b thanks for your reply. I downloaded Uday Rayala's (https://github.com/uday-rayala/video-trimmer ) video trimmer and recompiled it, After recompilation i found that my libffmpeg.so file was of 7.x mb where as Uday's libffmpeg has 5.x mb – Gaganpreet Singh Feb 27 '15 at 04:44
  • changing the APP_PLATFORM didn't solve your problem ? The file size difference doesn't mean a lot. There are many differences between the NDK and platforms behavior from now and the time Uday's project have been compiled. – ph0b Feb 27 '15 at 06:52
  • @ph0b , It didn't solved my problem – Gaganpreet Singh Feb 27 '15 at 09:15
  • signal() was an inline function until platform android-21. So if you're compiling against a former platform, your lib shouldn't look for the signal symbol. Are you sure your APP_PLATFORM variable is taken in account ? You have to recompile your libffmpeg.so file with it. – ph0b Feb 27 '15 at 09:46
  • @ph0b SUCCESS... after writting App_platform in Application.mk , earlier I written in Android.mk. Please write your answer below , I will mark as accepted. AND Lots of Thanks for help – Gaganpreet Singh Feb 27 '15 at 10:34
  • @ph0b , I am now trying to create a watermark application . I used command from site ffmpeg.org . But When trying to execute , I get an error in logcat : Unrecognised option filter_complex . My stackoverflow question is - http://stackoverflow.com/questions/28763388/andoid-ndk-ffmpeg-unrecognised-option-filter-complex – Gaganpreet Singh Feb 27 '15 at 11:02

1 Answers1

15

signal was an inline function until platform android-21, now it's not inline anymore.

When you use the ndk r10, android-21 is used by default but it's not fully retro-compatible with devices running former Android versions. In your case, signal can't be found on your device (but it would run properly on Lollipop).

When using the NDK, you should use the platform (APP_PLATFORM:=android-XX) that corresponds to your android:minSdkVersion.

So here you can set APP_PLATFORM:=android-15 inside Application.mk Makefile, and your lib will use the inline version of signal, so it will not look for its symbol at runtime.

ph0b
  • 14,353
  • 4
  • 43
  • 41
  • I am now trying to create a watermark application . I used command from site ffmpeg.org . But When trying to execute , I get an error in logcat : Unrecognised option filter_complex . My stackoverflow question is - http://stackoverflow.com/questions/28763388/andoid-ndk-ffmpeg-unrecognised-option-filter-complex – Gaganpreet Singh Mar 02 '15 at 08:37
  • Android Studio compile don't need Android.mk, use android.ndk gradle. How can I set "APP_PLATFORM" ? – Hugo Aug 07 '15 at 03:48
  • There is no clean way to do it yet. You can modify the compileSdkVersion to change the APP_PLATFORM version. I've reported this issue here: https://code.google.com/p/android/issues/detail?id=177530 – ph0b Aug 07 '15 at 08:49