如何在 Android 上减小 expo/react-native 应用程序的大小 [英] How to reduce the size of an expo/react-native app on Android

查看:19
本文介绍了如何在 Android 上减小 expo/react-native 应用程序的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 react native 和 expo 开发一个小型字典应用程序.

I am developing a small dictionary app by using react native with expo.

因为我正在编译为 Apk 文件.大小高达 30mb,安装到设备上后,大小达到 80mb.

As I am compiling to Apk file. The size goes up to 30mb and after having installed on a device, it goes to 80mb.

这正常吗?

有什么方法可以减小应用程序的大小?

Are there any ways to reduce the size of the app?

谢谢你们.

推荐答案

expo 用于开发应用程序,您应该迁移到 react-native 用于生产

the expo is for development the app you should migrate to react-native for production

  • 制作一个新的 react 应用程序react-native init"

从 Expo 项目复制源文件

Copy the source files over from Expo project

安装 Expo 项目的所有依赖项,除了 Expo 特定库.

Install all dependencies of the Expo project except Expo specific libraries.

app.json文件进行必要的调整

使用 exp 从 Expo 下载您的 Android 应用的签名密钥

Download the signing key of your Android app from Expo using exp

fetch:android:keystore 并设置它

fetch:android:keystore and set it up



这大大减少了您的应用程序,您还可以为 cpu 架构启用 proguard 和特定构建



This reduces your app dramatically you can also enable proguard and specific build for cpu architecture

buildTypes {
    release {
        debuggable false
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
 }



有关更多信息,请访问 https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640

在您完成并希望以较小的大小发布或只是不想使用本机库 expo 后,为您提供一个名为 ExpoKit 这也可以用于已经使用本机代码构建的 react 项目

after you done and want publish with less size or just wan't to use a native library expo give you an option called ExpoKit this also can be used with already build with native code react projects

1-运行命令expoject来添加ExpoKit(选择ExpoKit"选项)
(如果您手动复制文件或使用本机项目,则无需这样做)
2 - 使用 expo start 启动 expo 打包程序.让它继续运行并继续执行以下步骤.
3-android 和 ios 的链接库,此命令主要执行此 react-native 链接,有时这将不起作用,您应该手动执行此操作,因为这意味着访问expo.io/versions/latest/expokit/expokit" rel="noreferrer">expokit
PS:我没有对此进行测试,所以如果这不起作用,请通知我

1-run command expo eject to add ExpoKit (choose the "ExpoKit" option)
(no need to do this if you have copied files manually or using native project)
2 -start expo packager with expo start.Leave this running and continue with the following steps.
3- link library for android and ios, this command mostly do this react-native link, sometime this will not work and you should do it manually for this means visit expokit
PS: I didn't test this so if this not work inform me

这篇关于如何在 Android 上减小 expo/react-native 应用程序的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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