Local image assets from an expo-modules project not showing on Android

Please provide the following:

  1. SDK Version: 40 (expo-modules-core: 1.2.6)
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I’m working on a RN project that uses an expo-modules. Unlike on iOS, the local images are not showing.

The directory structure of the expo-modules project is:

expo-modules-project/
├─ build/
├─ src/
│  ├─ ...components...
├─ assets/
│  ├─ ...image-files...

How I bring the images:

<Image source={require("../assets/image.png")} styles={{ width: 100, height: 100}} />
  • The expo-modules project has image assets(.PNG) and <Image /> component that shows the assets.
  • No issues directly showing images on the host RN project. (Not using the expo-modules project)
  • Remote images are showing without any problem on both platforms through the expo-modules.
  • The images show up well on iOS, but not on Android through the expo-modules, and there’s no warnings or errors.
  • I’ve tried different image formats, sizes, styles of the component and different versions of Android SDKs.

Any idea where I should look into?

Turns out, there’s an issue with assets resolution when importing if from paths outside of the project’s root directory. There’s an issue thread on Metro’s GitHub that helped me fixing it. (Asset paths (httpServerLocation) invalid when asset is in watchFolders · Issue #290 · facebook/metro · GitHub)

1 Like

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