6

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.

My react-native version is 0.40.

halfer
  • 19,824
  • 17
  • 99
  • 186
Manjeet Singh
  • 4,382
  • 4
  • 26
  • 39

2 Answers2

13

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

devt3000
  • 5
  • 2
  • 7
Manjeet Singh
  • 4,382
  • 4
  • 26
  • 39
  • 3
    If your React Native project directory does not have index.android.js this command works for me " react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.bundle --assets-dest android/app/src/main/res/" – Seunope Mar 30 '18 at 13:58
  • I am running these commands: `react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/` `cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew installRelease` But some of the images are not coming while others are coming. – khateeb Oct 05 '18 at 14:49
  • @khateeb that is weird, but with the latest version of react-native you should replace "index.android.bundle" with "index.bundle" see Mesorale's comment – Manjeet Singh Oct 06 '18 at 14:02
  • @ManjeetSingh I tried that and it did not make a difference. – khateeb Oct 08 '18 at 07:06
  • I am also having this issue. Running `react-native bundle --platform android --dev false --entry-file app/index.js --bundle-output android/app/src/main/assets/index.bundle --assets-dest android/app/src/main/res/` command did not help. Any suggestion? – Pankaj Feb 08 '19 at 12:37
  • Already bundled. Just switched from ./gradlew bundleRelease to ./gradlew assembleRelease and I cannot get it to work! – JeremyF Jun 09 '20 at 19:45
0

try running this
npm start --reset-cache

chris
  • 194
  • 2
  • 10