EAS build generates bigger apk as well as aab compared to Classic build after upgrading from SDK 40 to 44

After we upgraded from SDK 40 to 44, the resulting builds (apk and bundle) are larger in size even with EAS build. Please note that we were using expo build (classic build) + enableDangerousExperimentalLeanBuilds to generate smaller app bundles which is now not applicable anymore. The new builds with EAS are smaller then classic build without enableDangerousExperimentalLeanBuilds but larger than classic build with enableDangerousExperimentalLeanBuilds.

  • Workflow: Managed
  • Expo SDK 44
  • eas-cli version: 0.45.1
  • expo-cli version: 5.0.3

We followed all EAS build docs as well as all SDK announcements from SDK 41 to 44 to understand the impact. We built both apk and bundle and found that both are larger (apk extracted from aab is also large, 13 MB to 15 MB).

There’s increase of ~2 MB when we were expecting 10x smaller builds as per the announcement :upside_down_face:

Below is package.json if that is relevent:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-community/datetimepicker": "4.0.0",
    "@react-native-community/netinfo": "7.1.3",
    "@react-navigation/drawer": "^6.1.8",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "expo": "^44.0.0",
    "expo-constants": "~13.0.1",
    "expo-dev-client": "~0.8.0",
    "expo-device": "~4.1.0",
    "expo-document-picker": "~10.1.0",
    "expo-file-system": "~13.1.2",
    "expo-firebase-analytics": "~6.0.0",
    "expo-intent-launcher": "~10.1.0",
    "expo-linking": "~3.0.0",
    "expo-media-library": "~14.0.0",
    "expo-notifications": "~0.14.0",
    "expo-print": "~11.1.0",
    "expo-sharing": "~10.1.0",
    "expo-splash-screen": "~0.14.1",
    "expo-sqlite": "~10.1.0",
    "expo-store-review": "~5.1.0",
    "expo-updates": "~0.11.5",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-alert-async": "^1.0.5",
    "react-native-autocomplete-input": "^4.2.0",
    "react-native-elements": "^1.2.7",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-modal": "^11.10.0",
    "react-native-picker-select": "^8.0.4",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-reanimated": "~2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-simple-toast": "^1.0.0",
    "react-native-table-component": "^1.2.1",
    "react-native-view-shot": "3.1.2",
    "react-native-web": "0.17.1",
    "react-native-webview": "11.15.0",
    "rn-pdf-reader-js": "^4.1.1"
  },
  "devDependencies": {
    "babel-preset-expo": "9.0.2"
  },
  "private": true
}

Improve in size on eas comes from the fact that we are building exactly what you have in package.json, If you are not using any packages that were not supported in classic builds then for android apk size should be similar as enableDangerousExperimentalLeanBuilds.

As for the size increase, it might be caused by the SDK upgrade, I recommend unzipping old and new apk and compare what actually increased, it might native code, but maybe the issue is with js bundle or assets.

you can also try switching to hermes, their binaries are smaller than jsc.

There’s increase of ~2 MB when we were expecting 10x smaller builds as per the announcement

Empty android app has around 2-3 MB, with react-native and some javascript engine maybe around 8-10MB is achievable in react native. expo init app with jsc will have apks around 12 MB, it should smaller with hermes

1 Like

@wkozyra

Thanks for detailed response.

That’s what we understood from EAS docs. However, I see many extra packages including below packages in the EAS production build logs. Highlighted ones are huge packages. Are these packages needed in product build (curious as package name includes “dev” so looks like this is for development only).

expo-application
expo-dev-launcher
expo-dev-menu
expo-error-recovery
expo-font
expo-json-utils
expo-keep-awake
expo-manifests
expo-modules-core
expo-structured-headers

Does this mean EAS = Classic Build + enableDangerousExperimentalLeanBuilds?

Thanks for suggestion. Will try and see if that works (and doesn’t break anything).

Are these packages needed in product build

Dev packages are for custom dev client and won’t be include in production builds, nothing from that list is added by eas, all those packages are dependencies of expo package except the dev ones. I think currently only expo-splash-screen is added automatically on eas(at least for sdk44)

Does this mean EAS = Classic Build + enableDangerousExperimentalLeanBuilds?

no
for ios enableDangerousExperimentalLeanBuilds was not supported
for android main difference is that you can also add any third party library

1 Like

Thanks @wkozyra

I am seeing above packages (including dev ones) in production build. Below is build details if that is helpful for you to see why this happens:

Build ID: 37b88615-41c0-41e0-acae-a8117fdf716c
Build type: EAS
Profile: production

Below is my eas.json (if that matters):

{
  "cli": {
    "version": ">= 0.45.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal",
      "releaseChannel": "internal"
    },
    "production": {
      "developmentClient": false,
      "distribution": "store",
      "releaseChannel": "eas-sdk-44"
    }
  },
  "submit": {
    "production": {}
  }
}

Is there anything wrong above due to which dev ones are added (potentially making build bigger)?

My question was only w.r.t. binary size.

Also, please let us know if there’s anything we can do to minimize binary size except hermes (which we will try in sometime) or eject :slight_smile:

dev packages should be on that list, it does not mean they are included in the build, with that said I also verified by building package with and without dev client in package.json and the difference is around 2MB for aab (not sure how it affects platform-specific apk size), so some part of those packages is included there. I brought that issue internally and we are working on a fix.

Also, please let us know if there’s anything we can do to minimize binary size except hermes (which we will try in sometime) or eject

you can remove dev client from package json until we fix the issue
eject will not affect your binary size, at this point the only way to minimize the size it is to minimize amount libraries/assets you are using

This is exactly what we found 2 days back. Thanks for confirming.

That would help.

We are planning to get rid of react-native-reanimated (if at all that’s possible) as it is huge package to see how much impact it has on binary size.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.