SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Resolving Size Discrepancy in Programmable Voice Android SDK for Android Apps

Issue:

Are you experiencing a size discrepancy with the Programmable Voice Android SDK?

The reported size footprint for the arm64-v8a architecture is 4.5 MB according to Twilio's documentation.
https://www.twilio.com/docs/voice/sdks/android/3x-changelog#welcome-to-the-programmable-voice-android-sdk.

However, if you build the app bundle and use Google’s bundle tool to generate architecture-specific APKs, the size appears to be closer to 12 MB or more.

 

Product:

Programmable Voice Android SDK

 

Cause:

The discrepancy arises because the Android Gradle tools plugin does not compress the .so files within dependencies by default when the dependency is pulled via Maven. This results in a larger APK size when compared to the size reported in Twilio's documentation, which is based on compressed .so files.

If you see a size discrepancy, you may be looking at the size of the .so file when it's not compressed inside the APK. When extracted from the .aar file, the uncompressed size is approximately 11.4 MB, but when compressed inside an APK, it is about 4 MB.

We take the measurements using  the APK Scale Tool (more details below). You can use it to verify the same results. If you extract the .so file out of the .aar file, the size is 11.4 MB uncompressed. When its compressed inside of an APK, it's about 4 MB (example shown below).

 
venv) user_name@XXXXXX delete-me-2 % ls -la jni/arm64-v8a/libtwilio_voice_android_so.so
-rw-r--r--@ 1 user_name  staff  11446712 Feb  1  1980 jni/arm64-v8a/libtwilio_voice_android_so.so
 
 

Resolution:

Add the following line to your APK's AndroidManifest.xml as an attribute to the application tag to ensure compression: 

android:extractNativeLibs="true"

AppAndroid.pngAppLib.png

This attribute will compress the APK's dependency .so files, aligning the size with Twilio's reported 4.5 MB for arm64-v8a.

In addition you can use the APK Scale Tool to verify the size measurements and ensure consistency with Twilio's documentation.
 

Additional Information:

The APK Scale Tool is open source, allowing users to inspect the code and understand how it works. The tool measures the app size impact by putting the .so file into an APK and comparing it to another APK without it. We can read how it works and look at its code here:
https://github.com/twilio/apkscale
 
Have more questions? Submit a request
Powered by Zendesk