[RN 0.64] Image component is not able to find images marked as .android.png & .ios.png
See original GitHub issueAs per react-native documentation
The image name is resolved the same way JS modules are resolved. In the example above, the bundler will look for my-icon.png in the same folder as the component that requires it. Also, if you have my-icon.ios.png and my-icon.android.png, the bundler will pick the correct file for the platform.
Folder Structure
assets
add.android.png
add@2x.android.png
add@3x.android.png
add.ios.png
add@2x.ios.png
add@3x.ios.png
Code:
<Image source={require(‘./add.png’)} />
Error:
Unable to resolve module add.png from AwesomeProject/App.js: add.png could not be found within the project or in these directories: node_modules
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7
Top Results From Across the Web
expo - Image component in react native is not able to find ...
png and my-icon.android.png, the bundler will pick the correct file for the platform. But when I am trying to load images according to...
Read more >Images - React Native
Images. Static Image Resources. React Native provides a unified way of managing images and other media assets in your Android and iOS apps....
Read more >Back up photos & videos - Android - Google Photos Help
You can automatically save your photos and videos to your Google Account with backup. ... from any device you're signed in to, but...
Read more >react-native-image-picker - npm
Post-install Steps. iOS. Add the appropriate keys to your Info.plist,. If you are allowing user to select image/video from photos ...
Read more >Displaying images with the React Native Image component
source will also accept a cache property that tells the component how to cache network images, but this only works for iOS. defaultSource....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Update: https://github.com/facebook/react-native/issues/31348#issuecomment-867298139
@irodeanu I was having this problem too. I ended up finding (just by tinkering around) that requiring images with these platform-specific extensions works fine if I just provide a default file.
So in your case, since you have
add.ios.png&add.android.png, try also picking one to version to be your default and copy it intoadd.png. I would be curious to know if that ends up working for you (and any others here that have experience this problem).If this is now the intended requirement for platform-specific image files, then perhaps it would be helpful to add a note to https://reactnative.dev/docs/images Right now it just says
So something like “you must also provide a default image file my-icon.png”
we got the answer to this issue in https://github.com/facebook/metro/issues/676#issuecomment-866712819