Closed Estebank94 closed 10 months ago
you should add file:// prefix on local image path. it maybe helps you
same problem
in my case the images are not displayed only in debug mode. Anyone had the same problem?
I'm experiencing the same problem too.
Issue only happens when loading an image from a path outside the project directory in debug mode.
React Native is somehow picking up the image dimensions properly & allocating the appropriate space on the view, but no image is displaying.
Works in Android release mode. Works in iOS debug & release mode.
A simple App.js using the example above will reproduce the problem.
export default function App() {
return (
<SafeAreaView>
<Image source={require('common/icon.png')} />
<Text>Hello world</Text>
</SafeAreaView>
);
};
I'm experiencing the same problem. Did you find a solution?
Check out this article, it might help: https://engineering.brigad.co/react-native-monorepos-code-sharing-f6c08172b417
I had this same issue in a monorepo and solved it by using https://www.npmjs.com/package/react-native-monorepo-tools
in your metro.config.js
const { getMetroAndroidAssetsResolutionFix} = require('react-native-monorepo-tools');
const androidAssetsResolutionFix=getMetroAndroidAssetsResolutionFix();
module.exports = {
// other stuff
transformer: {
publicPath: androidAssetsResolutionFix.publicPath, // <-- add this
// other stuff
},
// more stuff
server: {
enhanceMiddleware: (middleware) => {
return androidAssetsResolutionFix.applyMiddleware(middleware); // <-- add this
},
},
};
I hope that helps!
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
const androidAssetsResolutionFix=getMetroAndroidAssetsResolutionFix();
@markrickert you are the man, this fixed my issue 🙌🏼
Description
Local images do not display on Android but display correctly on iOS.
React Native version:
Steps To Reproduce
Expected Results
Local images should display correctly.
Snack, code example, screenshot, or link to a repository:
Because I share the same JS code and assets between two apps, my project has the following structure:
metro.config.js Because I share common code between two apps, I have set the following configuration:
projectA/android/app/build.gradle
I have tried clearing the cache, I tried on different computers but the error persists.