SDK size troubleshooting for Android

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 is fine 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.

The most significant parts of SDK in terms of space are:

  1. FFmpeg library for video operations;
  2. Face AR library for applying face effects;
  3. Other native libs;
  4. Bnb-resources with neural networks, luts, local effects. The size can vary based on the number of AR effects you include in your app;
  5. Classes.dex internal SDK code and libs, like android support library, androidx, exoplayer. Depending on whether you have some of those or not.

💡The SDK size with no AR effect will take around 51 MB.

Please, keep in mind that every AR effect takes 2 Mb, on average. The more effects you place in assets the more space it'll take in the apk file. Banuba is working on AR Cloud for storing AR effects for your app on the backend.

Release apk file should take fewer MBs than debug apk file due to Banuba Face AR SDK strips its resources.

What should I do if the released apk file size is big?

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:,,,,,,,,,,,,,

Follow these steps to fix the issue

  1. Find lib/arm64-v8a/ file. If this file size is bigger than expected (same or bigger than in debug) check your gradle scripts. Look for the option doNoStrip that should be off.
  2. Make sure you have installed Android NDK. If not please Install Android NDK. Android Studio -> SDK Manager -> SDK Tools -> Show Package Details(right-bottom) -> NDK, download the latest version. Set ndkVersion 'downloaded version' to build.gradle(in app module)
  3. Sometimes gradle mess 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