b.ben b.ben - 5 months ago 54
Android Question

React naive, Unable to resolve module for static image

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's 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 nothing fixed :(

Answer

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')} />