0

I don't know how to use .so files in my project. So I downloaded the ffmpeg.so file and now I need to add it to my solution so that I can convert video formats on my device but I do not know how. I tried finding tutorials on the internet on how to add this file but nothing seems to work for me.

Do I still need the Android NDK to compile my C code as I have the .so file.

Any good tutorials how I can add this library to my solution?

  • Does this achieve what you're looking to do? [ndk-how-to-use-a-generated-so-library-in-another-project](http://stackoverflow.com/questions/5669220/ndk-how-to-use-a-generated-so-library-in-another-project) – bjornruffians Feb 10 '14 at 12:18
  • If the Java API is not provided by the library, you need to create it by using the NDK. Adding a .so file in an android app is quit simple, just add it into /libs folder and load it at runtime with the command System.loadLibrary(ffmpeg.so); – nbe_42 Feb 10 '14 at 12:27
  • when loading System.loadLibrary("ffmpeg.so"); it is giving me this error Couldn't load ffmpeg.so from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.untitled-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.untitled-1, /vendor/lib, /system/lib]]]: findLibrary returned null – user3292775 Feb 10 '14 at 12:30

1 Answers1

1

Put the file named libffmpeg.so into libs/armeabi subdirectory of your project. You don't need NDK if you don't have C/C++ sources of your own.

A mistake that happen sometimes is that the Android name expectations are not met. The name must start with lib and end with .so.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Please supply details. Are you sure that the library you downloaded, is built for Android, and for **armeabi**? Look into the APK file you've built (it is a ZIP file with changed extension). Do you see the ffmpeg library packed inside? When you install the APK, does the system log show that the library is extracted to `/data/app-lib/‌​com.example.untitled-1`? – Alex Cohn Feb 10 '14 at 15:52
  • i managed to get it loaded. the error was when giving the path to the library i was giving libs/libffmpeg.so. The libs directory does not exsist instead one needs to write 'lib/libffmpeg.so' `System.load(this.getBaseContext().getApplicationInfo().dataDir + "/lib/libffmpeg.so");` – user3292775 Feb 10 '14 at 16:04
  • You can simply write `System.loadLibrary("ffmpeg")`. – Alex Cohn Feb 10 '14 at 19:05