Android Zoom SDK build folder is 300-450 mb

Description
I’ve read several posts here complaining of the SDKs absolutely massive size, however even in those reports the size of the APK “only” doubled or tripled.

Our release APK has gone from 50mb to over 250mb (with ProGuard enabled) after adding Zoom. This is utterly absurd. I’ve cleaned out the project and manually deleted the build folder in the mobilertc module (it doesn’t appear to get deleted during a normal Gradle clean task).

Upon rebuilding the project, the mobilertc folder is usually somewhere between ~320mb and ~430mb. It is not clear to me why it seems to vary in size. Navigating to the mobilertc/build directory shows the directory to be empty, but ls -a shows a hidden .transforms directory. This directory contains several unknown file types and multiple .bin binaries.

Questions:

  1. What is the mobilertc/build/.transforms directory?
  2. Why is the mobilertc/build/.transforms directory so large?
  3. How can we reduce the size of our APK to ensure our release APK does not exceed the size limit enforced by the Play Store?

Which version?
SDK version v5.0.24433.0616

Hi @caleb.c, thanks for the detailed post.

This is highly unusual and I completely understand how this could be concerning and frustrating. Hopefully we can get to the bottom of this ASAP!

We are aware that the size of our SDK is less than ideal (and would like to improve that), but it certainly shouldn’t be causing your APK size to go up that drastically. While we’re looking into this and trying to see if it’s reproducible, some additional info that could help speed up the process:

  • When you are cleaning/building the project, is that through CLI (i.e. ./gradlew clean) or through Android Studio’s build menu?
  • A snippet from your build.gradle where the SDK modules are added
  • A screenshot of your expanded mobilertc and commonlib modules in Android Studio (no need to expand the build directory for either one)
  • Is this a recent issue or has it been a problem since you first imported the SDK?
  • (If your app has multiple modules, excluding the SDK) Is the SDK being used in more than one module?

Thanks!

@jon.lieblich

When you are cleaning/building the project, is that through CLI (i.e. ./gradlew clean ) or through Android Studio’s build menu?

The clean tasks and build tasks referenced in my original post were all performed via Android Studio’s build menu.

A snippet from your build.gradle where the SDK modules are added

Both modules are simply added via:

implementation project(':commonlib')
implementation project(':mobilertc')

A screenshot of your expanded mobilertc and commonlib modules in Android Studio (no need to expand the build directory for either one)

Is this a recent issue or has it been a problem since you first imported the SDK?

This is the first release build we’ve built since implementing the SDK. We knew that the debug APKs had also drastically increased in size, but assumed that that was due to unused assets and files that would be stripped for a release build.

(If your app has multiple modules, excluding the SDK) Is the SDK being used in more than one module?

No, we have a single app module. The Zoom SDK introduced two modules, commonlib and mobilertc, bringing the total number of modules in the project to three.

Thanks for the prompt response!

@caleb.c thank you again for the detailed response.

Nothing in particular stands out that could be causing this, so let’s try some troubleshooting steps to see if we can resolve anything stemming from Gradle or Android Studio bugs.

  • Invalidate caches and restart - File -> Invalidate Caches/Restart -> Invalidate and Restart (in the dialog popup)
  • Completely remove the mobilertc and commonlib dependencies from your project and build.gradle, re-download the SDK, and then clean project & invalidate/restart again before adding the SDK back in
  • Update Gradle, Android Gradle Plugin, and build tools to the latest supported/stable versions (Android Gradle release notes, build tools)

If all of the above steps aren’t successful, the next step will have to be verifying that this is definitely being caused by the SDK. This could be a bit more involved of a process depending on your implementation. Basically, you would have to remove the SDK from your project again and comment out or delete all references to the SDK before generating your APK. If the size goes back down to the ~50MB size you previously noted, we can pretty confidently say that this is a bug with the Zoom SDK and investigate a fix on our end.

Thanks again, I look forward to hearing from you!

@jon.lieblich

Invalidate caches and restart - File -> Invalidate Caches/Restart -> Invalidate and Restart (in the dialog popup)

Invalidated and restarted twice, then built a fresh release APK. The result:
Screen Shot 2020-08-20 at 10.52.01 AM

Completely remove the mobilertc and commonlib dependencies from your project and build.gradle, re-download the SDK, and then clean project & invalidate/restart again before adding the SDK back in

I checked out an old commit from before Zoom integration, and removed the mobilertc and commonlib modules. A release APK built from this revision was the expected size, at roughly ~50mb. I then downloaded a fresh SDK from here. Afterwards, I added the modules from the fresh download to the project, as specified here. I then built another release APK on the same revision as before. As noted, this revision had no application code that utilized the SDK. Regardless, the APK was back to ~250mb, as shown below:

Screen Shot 2020-08-20 at 11.32.53 AM
v5.0.24437.0708

Update Gradle, Android Gradle Plugin, and build tools to the latest supported/stable versions (Android Gradle release notes, build tools)

I’ve updated Gradle, the Gradle Plugin, and Android Studio to the latest versions. These updates do not appear to have solved the issue.

If all of the above steps aren’t successful, the next step will have to be verifying that this is definitely being caused by the SDK. This could be a bit more involved of a process depending on your implementation. Basically, you would have to remove the SDK from your project again and comment out or delete all references to the SDK before generating your APK. If the size goes back down to the ~50MB size you previously noted, we can pretty confidently say that this is a bug with the Zoom SDK and investigate a fix on our end

Please see the comments above. Checking out the commit directly before the commit which integrated the Zoom SDK results in an APK around ~50mb, as expected.

Note that the increased size appears to be primarily caused by by the /lib directory, as shown below:

@caleb.c thank you for bearing with us through this process and providing extremely detailed responses, it’s greatly appreciated. :slightly_smiling_face:

Looking at the APK analyzer at least gives us a (temporary) solution for getting your APK size under the play store limit while we figure out the root cause. For that, we recommend creating one APK per ABI. Based on your APK breakdown, this would reduce the increase in size to between 25MB - 50MB, depending on ABI.

After setting up a project locally and integrating the SDK, I am seeing a total size of 21.6MB for the libs directory (only using one ABI though), so there’s definitely something else going on here. If you take the same steps of deleting and re-integrating the SDK into our sample app, are you still seeing a similar increase in APK size? This step will help greatly narrow down our potential causes.

Let me know if you have any questions. Thanks!

@jon.lieblich

For that, we recommend creating one APK per ABI. Based on your APK breakdown, this would reduce the increase in size to between 25MB - 50MB, depending on ABI.

APK splitting is not feasible for us. We’ve considered switching to App Bundles for distribution if a fix for this issue is not released, but even then we’d already be close to the 150mb limit defined by the Play Store.

I believe I have found a way to reliably reproduce the issue, even using the sample application provided by Zoom. The steps needed to reproduce the issue are as follows:

  1. Clone the repository.
  2. Update the project to the latest Gradle and Android Gradle Plugin versions (6.1.1 and 4.0.1, respectively).
  3. Zoom has migrated to AndroidX (https://github.com/zoom/zoom-sdk-android#latest-sdk-news), but did not set the requisite android.useAndroidX flag to true. As such, Gradle syncs will fail after updating the Gradle and Android Gradle Plugin versions. Create a gradle.properties file in the project root with an android.useAndroidX property set to true.
  4. Set the minSdkVersion to 23 (Marshmallow). Optionally, remove the explicit buildToolsVersion found in the sample app to ensure that the project uses the default version provided by the plugin.
  5. Create a signed release build, and observe the APK size.

The result:

Screen Shot 2020-08-20 at 7.02.43 PM

@caleb.c, thanks for testing it out with the demo app.

After following your steps and generating a release APK, I am seeing a significantly smaller size. Screen Shot 2020-08-21 at 11.44.09 AM

Since you’re able to reproduce this in the demo app, you obviously are not doing anything wrong with how you are integrating the SDK. The only possible difference that could be causing this would be our environments. If you’d like to confirm that, you could create an empty “Hello world” project in Android Studio and integrate the SDK before generating a release APK. If you’re still seeing something around 200MB after doing this, there must be something in your environment causing APK sizes to be greatly inflated.

Hope this helps!

@jon.lieblich

Are you absolutely positive you followed my instructions precisely? This issue has also been reproduced by a colleague of mine on his own machine, so I highly doubt the issue is with our environments. We are both using macOS.

Do you have anything set in your system level Gradle properties file?

I will attempt to reproduce the issue again using a blank project.

@jon.lieblich

I was able to reproduce the issue again on a newly created Android project.

Screen Shot 2020-08-24 at 11.05.33 AM

Given the large number of similar posts on this forum, the ability to reproduce the issue on both Zoom’s own sample applications and a newly created project, and the fact that another individual on another machine was able to reproduce the issue independently, it seems logical to assert that the problem is with the Zoom SDK.

@caleb.c, we were able to reproduce and have a solution! In your manifest, add the following attribute to your application element: android:extractNativeLibs="true".

All versions of AGP >= 3.6.0 set this to false by default and so it must be manually overridden. It is also only used in API levels 23+, which would explain why some other developers haven’t been seeing as drastic of a size increase (we support a minSdkVersion of 21+). Let me know if there are any issues with using this on your end.

Thanks!

@jon.lieblich

Setting android:extractNativeLibs="true" appears to reduce the APK size from about ~250mb to ~120mb. This is an improvement, but it’s still over the limit imposed by the Play Store. The lib/ directory alone takes up nearly ~90mb, leaving those who wish to implement the SDK only ~10mb for the rest of their application. Additionally, it’s my understanding that setting this flag to true results in a decrease in runtime performance (and increase in size on disk) as uncompressed native files will not be loaded directly from the APK.

Are there any other solutions? Again, leaving only ~10mb for the rest of the application is not feasible for most.

As an aside, do you have any idea what the libzChatApp.so file is? It is nearly 11mb for arm64-v8a alone.

@caleb.c, unfortunately the only other option I am aware of that could help get your APK size under 100MB is through one APK per ABI, which you’ve already mentioned is not an option for you. We hope to improve this in the future, but do not have a better option than that in the immediate term.

Thanks!

@jon.lieblich

We ended up moving to App Bundles. Even so, the App Bundle (~130mb) is already relatively close to the Play Store limit for App Bundles (150mb). We eagerly await any future updates that may reduce the size of the SDK.

I appreciate your help throughout this thread!

1 Like

Have you got the best solution yet? add android:extractNativeLibs="true it reduces the performance of the app a lot

Hi @danhloc, thanks for using the dev forum.

In addition to the extractNativeLibs attribute, another approach to help reduce APK size mentioned earlier in this thread is to use abiFilters in your build.gradle file. :slightly_smiling_face:

Thanks!