Nishanth Shankar
Nishanth Shankar

Reputation: 1976

React-Native Android: Unable to display static images

I am trying to display a static image(ic_launcher) in my android app using react native. I am getting a black response. No errors. Just a blank view as though the resource doesn't exist.I am able to display images from the network.

Upvotes: 3

Views: 2692

Answers (3)

Michał Kisiel
Michał Kisiel

Reputation: 1050

Your ic_launcher files are probably placed in android/app/src/main/res/mipmap-xxx directories. Try to move it to android/app/src/main/res/drawable-xxx directories.

Upvotes: 5

kzzzf
kzzzf

Reputation: 2664

You should use require('image!img_name') as a source attribute of Image component. See example app here https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/ImageExample.js#L84 with it's resource placed under https://github.com/facebook/react-native/tree/master/Examples/UIExplorer/android/app/src/main/res/drawable

Upvotes: 0

litaonet
litaonet

Reputation: 1

  • \android
  • |----\app
  • |----|---\src
  • |----|---|----\main
  • |----|---|----|---\res
  • |----|---|----|---|---\drawable
  • |----|---|----|---|---|---\ic_launcher.png

Upvotes: 0

Related Questions