Home > Software engineering >  How to reduce expo apk size for android?
How to reduce expo apk size for android?

Time:12-06

I have built an app using expo cli and when I run expo build:android its size is 65 mb. My app consist of only 7-8 screens.I have tried building .aab file but its size is also 62.5 mb. Is there any way to get my app <10mb ?

CodePudding user response:

Yes, you can reduce the size, but not with the expo.
The expo is a development tool, for production, you should use react-native.

Migrating to React Native

  • react-native init a new project with the same name
  • Copy the source files over from the Expo project
  • Install all dependencies of the Expo project except Expo-specific libraries.
  • Make necessary adjustments to the app.json file
  • Copy over your .git folder into the new project.
  • Download the signing key of your Android app from Expo using exp
  • fetch:android:keystore and set it up
  • Build and test your app

Reducing the size of React Native App (Android)

  • 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 architectures armebi and x86. By default, RN builds the native libraries for both these architectures into the same apk.

Set def enableSeparateBuildPerCPUArchitecture = true . Android devices support two major device architectures armebi and x86. By default, RN builds the native libraries for both these architectures into the same apk.

Reference:
For more information, you can see this tutorial. https://medium.com/@aswinmohanme/how-i-reduced-the-size-of-my-react-native-app-by-86-27be72bba640

CodePudding user response:

You can still achieve a much smaller build size without moving away from Expo, but you will need to use EAS (Expo Application Services) to build your project instead of Expo build.

You can find the documentation here: https://docs.expo.dev/build/introduction/.

  • Related