Local images are not visible in React-Native app release build

微笑、不失礼 提交于 2020-01-14 13:48:10

问题


In my react-native app I have "src" folder that includes a Images folder and screens folder.My screens folder have various components where I am uing local images from Images using following code.

<Image source={require('src/Images/logo.png')} />

logo.png is an image placed in Images folder, there are many more such images referenced like this.Now all these images are shown pretty well in development mode but when I generated the release apk using gradlew assemblereleaseand installed the apk on my device all images referenced in this manner disappear somewhere. Don't know what can be the reasons for that so please help me. my react-native version is 0.40


回答1:


Solved by following answer of Chiranjhivi Ghimire Steps -

  1. Created assets folder at ../android/app/src/main/
  2. copy and paste this command in command prompt

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

  1. enter this command in cmd gradle assemblerelease.
  2. done

equivalent solution for ios can be found at link



来源:https://stackoverflow.com/questions/41937443/local-images-are-not-visible-in-react-native-app-release-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!