[Android] Images are not showing using local assets or remote image.
See original GitHub issueReact Native version: React Native Environment Info: System: OS: Windows 10 CPU: (8) x64 Intel® Core™ i5-8300H CPU @ 2.30GHz Memory: 7.54 GB / 15.85 GB Binaries: Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338
Steps To Reproduce
Here’s the code
Poster.js
const Poster = ({ imageURL }) => {
const { width } = Dimensions.get("window");
console.log(imageURL);
return (
<View style={{ padding: 5 }}>
<Image
source={imageURL}
style={{
width: Math.floor(width / 2 - 30),
height: 300,
flex: 1,
borderRadius: 10,
}}
/>
</View>
);
};
It’s being called from here.
MovieGrid.js
....
<View style={movieGrid}>
<Poster imageURL={require("../images/image.jpg")} />
<Poster imageURL={require("../images/1.jpg")} />
<Poster imageURL={require("../images/2.jpg")} />
</View>
</View>
....
When I run the same app in the browser using Expo it works fine but when I run it on an emulator or a physical device it doesn’t show the images. In the Web Browser
On Emulator
Also require('../images/image.jpg')
returns a number
Working with images is such a pain 😥 Thank you for your time.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:22
Top Results From Across the Web
React Native Image not showing, How do i fix? - Stack Overflow
I was wondering why my image is not showing. What I want is for my image to be in the background with my...
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 >Assets - Expo Documentation
Learn about using local and remote assets. Images, fonts, videos, sounds, and any other file that your app depends on that is not...
Read more >Loading images | Jetpack Compose - Android Developers
Use the Image composable to display a graphic on screen. To load an image (for example: PNG, JPEG, WEBP) or vector resource from...
Read more >Why my image (local assets or downloaded assets) is not ...
Coding example for the question Why my image (local assets or downloaded assets) is not showing on iOS 14 but showing on Android...
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
Same thing, none of my emulators are showing images, regardless if they are local or remote. All of my images in both dev and prod are sent via HTTPS. They are not showing in my debug APKs or my release APKs. I have tried various Android emulators: 7, 8 and 9. iOS is working just fine, as usual.
“react”: “16.6.3”, “react-native”: “0.59.10”
Update
After running Android Studio and reviewing the logcat output I discovered a warning: “Dependency ‘:native-imagetranscoder’”
This lead me to: https://github.com/facebook/fresco
And in my android/app/build.gradle file I added…
This: “implementation ‘com.facebook.fresco:fresco:2.0.0’”
If you are using GIF’s you will also need need…
This: “implementation ‘com.facebook.fresco:animated-gif:2.0.0’”
And just like that my images are back…
I had the same issue and in my case, the solution was to give the image a default styling and resize mode.