What SDK consists of?
Sometimes you might notice that APK file size may differ due to the various environments and libraries you use. To make sure the app size corresponds Banuba take a look at the steps below.
First, let's analyze what the SDK includes in your APK file. We recommend using Analyze Apk tool in Android Studio to profile the apk size.
Release versions of the sample with optimizations enabled for version 21.0 take up about:
- 1 MB, an application without all libraries:
- 36.5 MB, application with the editor and Face AR module, without colour filters and AR masks:
- 13.7 MB, application with the editor and without Face AR module, AR masks and colour filters:
All listed APKs were built only for armv8, and for armv7 the build size will be smaller.
Also, about 1 Mb can be subtracted from this size, since most of the standard libraries will be used in your application and their code will not be duplicated as in our SDK example.
Our SDK currently includes 16 .aar files.
The two libraries ve-sdk and effect-player take up almost 90% of the total size of all libraries.
Most of it is taken by:
1) *.so FFmpeg libraries, separately for each architecture x86_64, x86, armeabi-v7a, arm64-v8a.
However, we are using the most lightweight version of the FFmpeg libraries, as we use only those needed for our functionality, and the full version of FFmpeg takes up more than 100 MB.
2) the files necessary for face recognition module work, stored in the assets archive such as folders frx, flow, MoMoFrx, android_nn.
Disabling the camera module subtracts 1.5 Mb.
💡The SDK size with no AR effect takes 43.2 Mb.
The minimum your application size can be increased when using Video Editor SDK is 35.3Mb (from 35.9 Mb to 0.6 Mb), 0.6 Mb is the size of an empty project.
architecture: armeabi-v7a
screen density: ldpi(least density)
Keep in mind that each AR mask takes about 2.5 Mb. The more effects you place in assets the more space it takes in the apk file.
Banuba also provides AR Cloud for storing AR effects for your app on the backend.
Release apk file should take fewer MBs than the debug one due to Banuba Face AR SDK strips its resources.
What should I do if the released apk file size is big?
Optimization could be done on your side if you use .aab for app delivery.
The size of the file that the user will download from the Google Play Store will be approximately 24-26 Mb smaller. There won't be extra libraries for FFmpeg and licenses from the Face AR module. A folder with libraries of a certain architecture will be selected.
Here you can find more information on the size of the application when using Android App Bundles.
Please make sure Gradle does not warn you with a message while gradlew build process.
***Task :app:stripDebugSymbols***
Unable to strip the following libraries, packaging them as they are: libavcodec.so, libavdevice.so, libavfilter.so, libavformat.so, libavutil.so, libbanuba.so, libffmpegexec.so, liblicence.so, libnative-camera-sdk.so, libnative-core-sdk.so, libnative-ve-effects-sdk.so, libnative-ve-sdk.so, libnative-ve.so, libswresample.so.
Follow these steps to fix the issue:
- Find lib/arm64-v8a/libbanuba.so file. If this file size is bigger than expected (same or bigger than the debug one) check your Gradle scripts. Look for the option doNoStrip that should be off.
- Make sure you have installed Android NDK.
You can do that as follows:
Android Studio -> SDK Manager -> SDK Tools -> Show Package Details(right-bottom) -> NDK, download the latest version.
Set ndkVersion 'downloaded version' to build.Gradle in the app module. - Sometimes Gradle messes up. Try to clean Gradle cache and Andriod Studio Gradle cache:
./gradlew clean
./gradlew cleanBuildCache
Android Studio -> File -> Invalidate Caches/Restart
//Clean gradle cache
rm -rf ~/.gradle/caches