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

查看:23
本文介绍了如何减小 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

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

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-run 命令 expo eject 添加 ExpoKit(选择ExpoKit"选项)
(如果您手动复制文件或使用本机项目,则无需执行此操作)
2 - 使用 expo start 启动 expo 打包程序.保持运行并继续执行以下步骤.
3-android 和 ios 的链接库,此命令主要执行此 react-native link,有时这不起作用,您应该手动执行此操作,这意味着访问 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天全站免登陆