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

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

问题描述

我正在通过使用expo native来开发一个小型词典应用程序.

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?

谢谢你们.

推荐答案

世博会是用于开发的应用程序,您应将其迁移到本机以进行生产

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

获取: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'
    }
 }



有关更多信息,请访问完成并希望以较小的大小发布或者只是不想使用本机库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-运行命令expo eject以添加ExpoKit(选择"ExpoKit"选项)
(如果您手动或使用本机项目复制了文件,则无需执行此操作)
2-使用expo start启动expo打包程序.保持运行状态,然后继续以下步骤.
3 android和ios的链接库,此命令通常会执行react-native link,有时这将不起作用,您应该手动执行此操作,因为这意味着请访问

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天全站免登陆