4

I am using FFmpeg in my application and as a result of its GNU Lesser General Public License, version 2.1 I need to provide a way for the user to load their version of FFmpeg during runtime inside the app. Here is an example of app "Bandlab" that does this.

enter image description here

I tried to load the custom libraries with

System.load(PATH_TO_LIBRARY);

but this crashes my app and the log is the following:

E/AndroidRuntime(22353): FATAL EXCEPTION: main E/AndroidRuntime(22353): Process: com.insync.loopad, PID: 22353 E/AndroidRuntime(22353): java.lang.UnsatisfiedLinkError: dlopen failed: library "/storage/emulated/0/Android/data/com.insync.myApp/files/FFmpeg/libavcodec.so" needed or dlopened by "/apex/com.android.runtime/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"

I read it here that I can not use this call to load a compiled native library at runtime. So I wonder how did this app achieved this? Can someone help me on this one?

cs guy
  • 400
  • 1
  • 5
  • 19
  • https://stackoverflow.com/questions/4725773/ffmpeg-on-android – guest Mar 07 '21 at 18:45
  • this does not relate to my question? – cs guy Mar 07 '21 at 22:02
  • Need additional information. Check architecture on your phone "adb shell cat /proc/cpuinfo | grep rch". The common outputs: Architecture 7 -> 32bit or Architecture 8 -> 64bit. Check that you provide library version for this architecture. Moreover check that you provide libraries for the following ABI list: armeabi-v7a arm64-v8a x86 x86_64 https://developer.android.com/ndk/guides/abis. Also maybe this issue can be helpful https://stackoverflow.com/questions/59608865/library-is-not-accessible-for-the-namespace-classloader-namespace. – guest Mar 08 '21 at 20:42
  • im using arm64-v8a complied .so files with a arm64-v8a phone, the reason is android doesnt allow you to dnymically load libs outside apk as seen in the article, so I wonder how did these companies achieved this – cs guy Mar 08 '21 at 21:46
  • As far as I know this is not possible to do since Android 7.0. Have you tried to load a custom ffmpeg version in the app you mention? It's possible that they implemented it before Android 7 and left it there but it doesn't actually work anymore. – Dalmas Mar 16 '21 at 22:04
  • @Dalmas i did not try but i highly doubt what you are saying is true because this app is one of the famous music app there is and people would just sue them if it was just there for show and also there is another app called eDjing and they have the same literally 1 to 1 copy of this page on their app – cs guy Mar 16 '21 at 23:34
  • Did you make sure to request runtime permissions for storage (https://stackoverflow.com/questions/43148879/how-to-get-read-external-storage-permissions)? Also, did you include FFMpeg's dependencies as static libraries (https://stackoverflow.com/questions/4725773/ffmpeg-on-android)? You should be able to use `System.load()` then – Miki Mints Mar 17 '21 at 07:43
  • @csguy do you have your app accessible anywhere, for instance on github? – Anatolii Mar 17 '21 at 09:09
  • @Anatolii I don't have it as accessible anywhere – cs guy Mar 17 '21 at 11:58
  • I included read external permission yes, I think the problem is android os doesn't allow loading libraries outside the APK for security reasons @Miki – cs guy Mar 17 '21 at 11:59
  • I think your solution should work, provided you also load all other dependencies of FFmpeg before loading the user-selected file. Did you make sure to load `libavcodec` as well? – Miki Mints Mar 17 '21 at 14:29

0 Answers0