How to reduce Android APK size in react-native?(如何在 react-native 中减小 Android APK 大小?)
问题描述
我正在开发 react native 项目,但是每当我构建 Apk 文件时,它都会给我 47MB 的 Apk.我尝试了所有在谷歌上发现有用的文档,但对我没有用,有没有办法将我的应用程序大小减少到 10MB 以下,因为该应用程序只包含三页或四页.任何帮助将不胜感激
I am working on react native project , but whenever i am building an Apk file , it give me Apk of 47MB. I tried every documentation which i found useful on google but nothing works for me, Is there any way to reduce my App size below 10MB as the app only contain three or four pages. Any help would be appreciated
推荐答案
您可以尝试以下步骤
- 打开
android/app/build.gradle
- 设置
def enableProguardInReleaseBuilds = true
这将使 Progaurd 能够压缩 Java 字节码.这会稍微减少应用程序的大小 - 设置
def enableSeparateBuildPerCPUArchitecture = true
.Android 设备支持两种主要的设备结构 armebi 和 x86.默认情况下,RN 将这两种艺术的原生库构建到同一个 apk 中.
- Open up
android/app/build.gradle
- Set
def enableProguardInReleaseBuilds = true
this would enable Progaurd to compress the Java Bytecode. This reduces the app size by a tad bit - Set
def enableSeparateBuildPerCPUArchitecture = true
. Android devices support two major device artitectures armebi and x86. By default RN builds the native librariers for both these artitectures into the same apk.
设置最后一个函数会在 build 文件夹中创建两个不同的 apk.您必须将此 apk 上传到 Play 商店,Google 会负责将应用程序分发到正确的架构.使用此拆分为两个 apk 生成版本号,顺序为 104856 等.这是由构建自动生成的以避免版本冲突,所以不要惊慌(我做过).这种拆分将 apk 的大小从 7MB 减少到 arm 的 3.5MB 和 x86 的 5MB.
Setting the last function creates two distinct apk in the build folder. You have to upload both of this apk to Play Store and Google would take care of distributing the app to the correct architectures. Using this split generates version numbers for both apks in the order of 104856 and such. This is auto-generated by the build to avoid version conflicts, so don’t freak out (I did). This split reduced the apk size from around 7MB to 3.5MB for arm and 5MB for x86 respectively.
您可以在这篇文章中找到更多信息 https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640
You can find more information in this article https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640
这篇关于如何在 react-native 中减小 Android APK 大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 react-native 中减小 Android APK 大小?
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01