React Native 用于低互联网带宽的小尺寸 apk [英] React Native for small size apk with low internet bandwidth

查看:68
本文介绍了React Native 用于低互联网带宽的小尺寸 apk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划为互联网带宽较低的新兴市场开发一款应用.该应用程序非常需要互联网连接才能运行.
我需要这个应用程序有一个小的 apk 大小(不超过 10mb)并在 3G 网络上工作.
根据我的研究,如果我从 React Native 中删除 x86 JS 二进制文件,apk 大小可能会小到 4mb.我想 4mb 不包括 JS 文件和图像,所以客户端需要在他/她打开应用程序时第一次下载,对吗?
如果我想要一个可在 3G 上运行的小于 10mb 的 apk 大小的应用程序以及使其高效的最佳实践,那么使用 React Native 对我来说通常是个好主意吗?

I am planning to develop an app for emerging market with low internet bandwidth. The app heavily requires an internet connection to function.
I need this app to have a small apk size (not more than 10mb) and work on 3G network.
Based on my research if I remove x86 JS binary files from React Native the apk size could be as small as 4mb. I suppose the 4mb does not include the JS files and images so client needs to download that first time when he/she opens the app, is that correct?
Would it in general be a good idea for me to use React Native if I want an app with less than 10mb apk size that works on 3G and what are the best practices to make it efficient?

推荐答案

相反,删除影响很小的 js,您应该使用二进制资源,例如字体和嵌入图像.除此之外,以下技术可能对您有用:

Instead removing js which have very less impact you should go after binary resources such as font and embedded images. Apart from that these are following techniques that may work for you:

1) 启用 Proguard:

1) Enabling Proguard:

要启用 Proguard,请编辑 android/app/build.gradle:

To enable Proguard, edit android/app/build.gradle:

def enableProguardInReleaseBuilds = true

生成单独的构建:

2) 在你的 app/build.gradle 集合中

2) In your app/build.gradle set

def enableSeparateBuildPerCPUArchitecture = true

3) 从 abiFilters 中删除 x86

3) Remove x86 from abiFilters

以下是对您可能有用的链接的引用:

Following are references to links that you may find useful:

关于减小 apk 大小的博客:

Blog on decreasing size of apk:

https://realm.io/news/reducing-apk-size-native-libraries/

链接 Play 商店中最小的 RN 应用之一:

Link one of smallest RN app on play store:

https://github.com/sonnylazuardi/ziliun-react-native

关于 React Native 问题的关于 apk 大小的有用讨论:

Useful discussion on React Native Issue regarding apk size:

https://github.com/facebook/react-native/issues/5037

这篇关于React Native 用于低互联网带宽的小尺寸 apk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆