简体   繁体   English

从 Android Studio 中的 apk 中排除模块

[英]Exclude module from apk in Android Studio

I integrating Zoom Sdk to my application.我将 Zoom Sdk 集成到我的应用程序中。 Zoom Sdk adds ~80Mb to the release apk after build. Zoom Sdk 在构建后向发布 apk 添加了 ~80Mb。 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.我想以某些方式从我的最终 apk 中排除所有缩放代码,以节省小尺寸的 apk。 How to do it?怎么做? It will be good if you suggest me solution that excludes zoom module during apk assembling.如果您建议我在 apk 组装过程中排除缩放模块的解决方案,那就太好了。

UPDATE:更新:

Zoom includes not in app directly, it includes transitevly via other core module: app<--core<--zoom缩放不直接包含在应用程序中,它通过其他核心模块传递: 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.我希望有一个解决方案可以在构建 apk 期间使用包含或排除缩放模块的参数来实现core依赖。 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-post: 如何为不同的产品风格定义不同的依赖

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 .另一种方法是使用 android 动态特性模块交付与按需交付 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.由于缩放模块的大小将大于 10 MB,因此用户会看到一个系统对话框,询问是否可以下载该功能。 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在此处查看如何使用动态功能模块:https://developer.android.com/guide/app-bundle/dynamic-delivery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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