1

My local assets images are working fine on Debug mode. but when i build apk in release mode with command react-native run-android --variant=release at first all local images showing correct but after sometime while using app some image not showing and some are fine. i fix this issue by add android:largeHeap="true" this line in AndroidManifest.xml but this reduce app performance. can anyone help me how can i handle this problem?

Issue is on android i didn't test this on ios.

React Info:

react: 16.9.0 => 16.9.0 
react-native: 0.61.2 => 0.61.2 
Mohit Karkar
  • 71
  • 1
  • 9

3 Answers3

1

You should try

cd android && ./gradlew assembleRelease

to see if your images are present in the generated release apk in the outputs folder. If so, then your release shouldn't have this issue.

0

Try to bundle all your assets before release apk file using this code:

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/

After that move to your android folder and make release build using this:

cd android && ./gradlew assembleRelease

If the above answers didn't help you try to run this all in one code inside your project root folder

mkdir -p android/app/src/main/assets && rm -rf android/app/build && 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 assembleRelease
Akila Devinda
  • 5,054
  • 3
  • 19
  • 35
  • it show me error ` Task `:app:mergeReleaseResources FAILED /android/app/build/generated/res/react/release/raw/app.json: Error: Duplicate resources` – Hussnain Ghani Mar 02 '20 at 08:51
  • So that is issue with your assets are being duplicated - https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android – Akila Devinda Mar 02 '20 at 08:57
  • 1
    issue fixed by building apk with `cd android && ./gradlew assembleRelease` this command. without this `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/` i will also try with `./gradlew clean` thanks for help. :) – Hussnain Ghani Mar 02 '20 at 09:13
0

if you have index.android.js in the project root then run:

npx react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug

if you have index.js in the project root then run:

npx 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
Muhammad Haidar
  • 1,541
  • 16
  • 17