0

I am using FFmpegKit to resample audio files.

The apk contains many SO files in the lib folder.

enter image description here

I believe that only a few of these SO files are relevant to me. So, in order to reduce the apk size, I would like to remove these SO files one by one and test the functionality.

How should I go about doing this?

Ritesh Singh
  • 279
  • 1
  • 4
  • 19
  • 1
    If a library A contains a functionality that makes use of another library B you need both of them even if yo never call the method that requires library B. Use a Linux system and `ldd` to see what libraries are required by a executable or library. https://stackoverflow.com/q/50159/150978 The only way to make a library smaller or remove dependencies is compiling it yourself and change the compile arguments (config parameters) what functions the library should support and what not. – Robert May 20 '23 at 17:55

1 Answers1

1

You can put these lines of code in the android block of your Gradle file to exclude unnecessary .so files like this:

 android {
    // ...

    packagingOptions {
        resources {
            excludes += "lib/*/libavformat.so"
            excludes += "lib/*/libavfilter.so"
        }
    }
 }
  • Thank you so much hosein. However, this doesn't seem to work at my end. Even after adding `excludes += "lib/*/libavcodec.so"`, the libavcodec.so becomes part of the apk. – Ritesh Singh May 22 '23 at 04:01
  • `libavcodec` normally is the core lib if you want to encode/decode data for example. Besides maybe even avformat / avfilter depend on that, not sure. To reduce size it's normally not enough to just remove files without breaking the functionality. Or you check if the package (ffmpegkit) has a minimum build or rebuild the package itself tweaking the internals. I think ffmpegkit allows you to build it with custom ffmpeg. So it's good to investigate how to configure and build ffmpeg itself first (cross-compiling from Linux for example), gives you more freedom to adjust what you need. – mortalis Aug 18 '23 at 21:07