【问题标题】:facebook or Uber react native app size is so smallfacebook 或 Uber 反应原生应用程序大小是如此之小
【发布时间】:2022-02-17 16:06:02
【问题描述】:

我正在尝试一个响应本机应用程序,它只需要一个电话号码和国家代码。 这个应用程序大小为 60mb。而同样基于 React Native 构建的大型 apk,例如 facebook 和 uber,大小约为 100 mb。

这怎么可能?

我什至也试过这个。

 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.

【问题讨论】:

  • 这能回答你的问题吗? React Native initial App size is too large
  • AAB 是在 Play 商店发布时减小尺寸的解决方案。更多信息,请参考:stackoverflow.com/a/60631207/10657559
  • @Thanhal 创建 aab 后大小为 9 mb。但是 java/kotlin 中的类似应用程序是 1-2 mb
  • 是的,因为我们正在使用一些初始包来运行 React Native 项目。但是通过比较通用apk的大小和aab之后的大小来看看好的一面

标签: java android react-native google-play


【解决方案1】:

您必须优化您的应用程序大小。您可以通过一些方法优化应用的大小

- Remove unused libraries from `package.json`
- Remove unused `imports` from all the files in the app.
- Remove unused assets including Audio, Video and Images files
- Resize the images which are using in the app.
- Using Hermes, is an open-source JavaScript engine optimized for React Native. 
  For many apps, enabling Hermes will result in improved start-up time,
  decreased memory usage, and smaller app size.

更多详情Hermes

【讨论】:

    【解决方案2】:

    除了上面提到的@Nooruddin-Lakhani 的所有问题,这也可以提供帮助:

    还请记住生成版本,因为 Bundle 会对您有所帮助!

    【讨论】:

    • 他在问题中已经提到了
    • 你能解决吗?我看不到@Thanhal
    • 直接来自我什至也尝试过的问题。打开 android/app/build.gradle 设置 def enableProguardInReleaseBuilds = true 设置 def enableSeparateBuildPerCPUArchitecture = true .
    • 你是对的,我编辑了答案@Thanhal
    猜你喜欢
    • 2018-07-20
    • 2021-08-12
    • 1970-01-01
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多