简体   繁体   中英

Exclude module from apk in Android Studio

I integrating Zoom Sdk to my application. Zoom Sdk adds ~80Mb to the release apk after build. But I have a lot of flavors of my app and only one or two of them actually use zoom. All other apps are releasing without using zoom feature.

I want to exclude all zoom-code from my final apk in some flavors to save small size of apk. How to do it? It will be good if you suggest me solution that excludes zoom module during apk assembling.

UPDATE:

Zoom includes not in app directly, it includes transitevly via other core module: app<--core<--zoom

I can't read flavor of app inside of core module. I expect there is a solution which can implement core dependency with kind of parameter which includes or excludes zoom module during building an apk. Kinda:

implementation project(":core", withZoom = true)

or

def coreModule = project(":core")
coreModule.setParam("zoom", true)
implementation coreModule

You can define dependencies for specific flavors. Check out this SO-post here: How to define different dependencies for different product flavors

So you could add the zoom dependency only for the two flavors which need them.

Another method is using android dynamic feature module delivery with on-demand delivery . This allows you to download a module only if your app requests it. Since the size of your zoom module would be bigger than 10 MB, the user would see a system dialog which asks if the feature can be downloaded. This is not great for the user experience but it is a way to reduze the app size for the other flavors.

Check out how to use dynamic feature modules here:https://developer.android.com/guide/app-bundle/dynamic-delivery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM