Bundling assets for offline not working on ExpoKit 29?

My assets are not getting bundled into my ExpoKit iOS or Android apps (SDK 29), despite using some patterns that I am pretty confident are correct.

My assets are in the following folder structure:

40%20PM

Everything under the expanded folders is either a png or a jpg (there’s also usually an index.js that I use just to consolidate the reference, as well).

And my patterns are:

"assetBundlePatterns": [
      "app/assets/clubs/*.jpg",
      "app/assets/icons/apps/*.png",
      "app/assets/icons/inputs/white/*.png",
      "app/assets/icons/inputs/color/*.png",
      "app/assets/icons/tabs/*.png",
      "app/assets/icons/ui/*.png"
    ],

This is also in my app.json, though I’m not sure what impact it has (UPDATE: I’ve confirmed that removing it has no effect):

"packagerOpts": {
      "assetExts": [
        "ttf",
        "mp4",
        "png",
        "jpg"
      ]
    },

Is there anything I can do to troubleshoot why these are not getting bundled (I can tell they’re not because they don’t appear when offline)? For instance, I see a bunch of asset_1231293439743943-ish files listed in shell-app-manifest.json, but I can’t seem to find those files anywhere. Thank you!

I’ve made a minimal example demonstrating this issue. It appears that asset bundling is not working with ExpoKit 29. Here is the github repo. This example is based on the “blank” starting point when you run expo init. All I did was add a single png image asset and change App.js to show that image in them middle of the screen. The example already has an assetBundlePattern and an assets folder in app.json that I did not change. I tried this particular example out an Android, building a signed release app. I did not do a release build on iOS yet just because I’d have to go through getting new certs, TestFlight, etc.

Test steps:

  1. Run expo start.
  2. Run the app on a device in Android Studio (debug mode).
  3. You’ll see a gray screen with a beer icon in the middle of it.
  4. Run expo publish.
  5. In Android Studio, go to Build → Generate Signed APK, follow the prompts to build an APK.
  6. Install the APK (I’m using the “prodMinSDK prodRelease” APK… I think that’s the one I want to use?).
  7. Put the device in airplane mode.
  8. Start up the app.
  9. You should not see an image- just a gray screen.

One other interesting/ odd thing - even if I leave the network on when I start the Android app, I still generally do not see the image. On my own app, with several screens, I’ve noticed that some images never appear on the release build since I’ve upgraded to Expo 29. Sometimes it’s changed from build-to-build. Generally, I always see a few smaller images that are used repeatedly and show up on a deeply-embedded dialog (maybe these are not timing out/ have multiple opportunities to load from the network). I do not see this particular issue on iOS - the images either load if I’m on the network, or fail to load if I’m not. In both cases, I’m not trying to prefetch images, as I’ve been advised that is not needed for standalone apps with assetBundlePatterns.

I’ve uploaded an example APK demonstrating this issue to my example, as well - it is in the root folder and is called “test.apk”.

Some other info:

  • I did notice that shell-app-manifest.json is showing a bunch of bundled assets (with randomized filenames, of course) for both platforms.
  • I was able to unzip the IPA on my original project and see the assets in there (with filenames that matched the ones in shell-app-manifest). I unzipped the Android APK, looked around a bunch of places, but don’t really know where to look, and didn’t find any of my image assets.

Possibly related to:

more info:

Thanks! @sjchmiela alerted me to this issue on Slack just a while ago. It is related. By adding the code:

import { Asset } from 'expo';
Asset;

to App.js (same as reported in the issue) and updating the version in the Podfile to 2.7.4, offline assets now work on iOS. The same/ similar fix (for Android, the expokit node module should be on version 1.4.0) did not work on Android, and produced a slightly different error, so I’ve opened an issue here: https://github.com/expo/expo/issues/2105.

Hi all, I confirmed this bug exists, sorry! A short explanation can be found here.

As a fix, please replace your current expo.gradle contents with https://gist.github.com/sjchmiela/c73b16008d886f2f55308c7e495479f7.

4 Likes

I just confirmed this worked for me! Thanks so much for your help!

1 Like

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