简体   繁体   English

Instant Apps:如何添加外部库?

[英]Instant Apps: How to add external libraries?

I want to build an android instant app from my previous app.My main source code is less than 4 MB (Instant App Requirement). 我想从以前的应用程序构建一个android Instant应用程序。我的主要源代码不到4 MB(即时应用程序需求)。 But I am using some external libraries those have a size of approx 39 MB. 但是我正在使用一些外部库,它们的大小约为39 MB。 How I can shrink the code to 4 MB? 如何将代码缩小到4 MB?

Is there any possible way to load the libraries dynamically from the internet? 有没有可能从Internet动态加载库的方法? Or shrink my code to 4 MB? 还是将我的代码缩小到4 MB?

截图

You can reduce your APK size greatly by using App Bundles , which will build split APKs for you (or just do the splits yourself). 您可以使用App Bundles大大减少APK的大小,这将为您构建拆分的APK(或者您自己进行拆分)。 In your case, only one architecture will be delivered. 在您的情况下,将仅提供一种体系结构。

On that same page, you can also read about dynamic feature modules. 在同一页面上,您还可以阅读有关动态功能模块的信息。 You can develop them now, but uploading to Google Play isn't available to all developers yet. 您可以立即进行开发,但是尚不支持所有开发人员都可以上传到Google Play。

This may not work for extracting a library unless it's well encapsulated with the user facing feature and code that uses it in your app. 除非将库与面向用户的功能和在您的应用中使用该库的代码很好地封装在一起,否则这对于提取库可能不起作用。 So, if your app can't launch without the library, it will not help much. 因此,如果您的应用程序无法在没有该库的情况下启动,那将无济于事。

Also relevant, Google announced a 10MB beta program to increase instant apps size limit: http://g.co/instantapps/10MB 同样相关的是,Google宣布了一项10MB的Beta版计划,以增加即时应用程序的大小限制: http//g.co/instantapps/10MB

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

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