How to reduce the size of an expo/react-native app on Android

后端 未结 9 1083
渐次进展
渐次进展 2020-11-30 20:12

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

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

9条回答
  •  佛祖请我去吃肉
    2020-11-30 20:54

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

    • make a new react app "react-native init"

    • Copy the source files over from Expo project

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

    • Make necessary adjustments to app.json file

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

    • fetch:android:keystore and set it up



    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'
        }
     }
    



    for more info visit https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640

    using expo component

    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 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

提交回复
热议问题