Assets are not loaded in standalone app when offline


#1

Hi. I’m using assetBundlePatterns in app.json to pack image assets directly into bundle, but it doesn’t work as expected in standalone app (in my case, it is android apk), created with exp build:android.

When resources are accessed with require('path/to/resource'), assets not loaded either with or without internet connection. If they are accessed with Expo.Asset.fromModule, they are loaded only from network if available.

I managed to write simple workaround, which seems to work.

static assetFromModule(moduleObject) {
  const expo_asset = Expo.Asset.fromModule(moduleObject);
  return {
    uri: expo_asset.localUri || expo_asset.uri,
    localUri: expo_asset.localUri,
    width: expo_asset.width,
    height: expo_asset.height,
    hash: expo_asset.hash,
    type: expo_asset.type,
    name: expo_asset.name
  };
}

But is it really necessary? Perhaps I miss something? Images loaded in apk bundle as expected.
Here is my app.json:

{
  "name": "ast-connect",
  "displayName": "AST Connect",
  "expo": {
    "name": "AST Connect",
    "slug": "ast-connect",
    "sdkVersion": "26.0.0",
    "platforms": ["ios", "android"],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./icons/appicon.png",
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.ast.connect"
    },
    "android": {
      "package": "com.ast.connect"
    },
    "assetBundlePatterns": [
      "icons/*"
    ]
  }
}

closed #2

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