Assets included in build? yes/no

Please provide the following:

  1. SDK Version: 35.0.0
  2. Platforms(Android/iOS/web/all): Android/iOS

Hello,
I am working on an an Expo app that will be released for iOS and Android. When I go to submit my app to the Google Play Store, it is rejected for being over 100mb. Since I work for a school and they are not interested in allowing Google to sign app-bundles(.aab), we are stuck submitting an APK that I am generating using ‘expo build:android -t apk’.

Since this method is generating an apk that is too large to submit, I am attempting to reduce the size. One thing I’m curious about is if Expo hosts the image assets to be downloaded/cached when run for the first time (or if there is an update published), do I need to include the image assets in the build folder hierarchy (ex ProjectFolder/assets/img/…myimagefiles.png), or can they be removed once published (expo publish) to reduce final APK file size?

If this is not the case, can someone recommend ways to reduce apk file size when I have a not insignificant amount of images and some audio files that my app uses? I intend to use Expo’s push notifications and the ability to publish over-the-air updates, so I do not really want to eject.

The only assets that are included in your APK are the ones that are included in assetBundlePatterns. If you don’t include them in assetBundlePatterns, they are still uploaded to Expo’s servers and will be downloaded by your app if they’re not already available. You can use an asset loading pattern like this one to download all of your assets right when the app starts. If any of the assets you try to download are already available in the APK, then it will use the bundled version instead.

That said, if you download the assets, you have the be prepared for the possibility that the download will fail due to network issues, etc.

Might be worth trying again to get them over their AAB weirdness. Not sure what the hangup is there. They’re obviously trusting Expo with all the stuff for your app on their servers (with which I think one could do much more damage than Google could with your signing key, which is secured behind your probably-multi-factor-authenticated Google account).

So does this mean that the Image assets (and Audio assets) are not contributing to my APK’s file size? If that is the case, why would my APK be 150mb?

EDIT: looking at my app.json, my appbundlepatterns looks like this:
“assetBundlePatterns”: [
“**/*”
],

Is this the standard and is it including everything in hierarchy into my apk? Sorry, while I was digging through documentation, I somehow didn’t see the things related to this size issue.

That pattern matches on every file in your project, so it’s including all images, fonts, and video, including possibly some you don’t need (like your app icon and splash screen don’t need to be included in assetBundlePatterns- they’re added to your app automatically in a different way).

Thanks for this info. So, if I change that to be along the lines of:

 "assetBundlePatterns": [
    "assets/audio/*"
 ]

In that instance, only the audio files would be included in the build(in the APK itself), but the image files would not be included. The image files instead would be hosted on the Expo CDN and downloaded/cached on first run of the application to be stored on local device memory for next use, reducing the size of the initial APK.

Did I understand that correctly?

Thanks again for taking the time.

that’s correct

1 Like

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