React native, Unable to resolve module for static image

b.ben picture b.ben · Dec 8, 2015 · Viewed 26.6k times · Source

I'm using react-native 0.14.1

react-native run-android

[3:10:56 PM] <START> find dependencies
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js
Unable to resolve module image!ic_action_android_back_white3 from /Users/lion/Desktop/Developer/AwesomeProject/NewTrackActivity.js

If I force open my app in Genymotion it can't find my image.

Requiring unknown module image!ic_action_android_back_white3

I'm tried to move image to both ./android/app/src/main/res/drawable-xxx and ./assets/drawable-xxx but neither work.

Answer

purii picture purii · Dec 10, 2015

Have you tried to mount the image, like the new asset manager allows you to do? It's described in the documentation.

Use the following prop for the Image component. Choose the right relative path and dont forget the extension.

<Image source={require('./my-icon.png')} />