Search code examples
androidreact-nativeandroid-build

React-native : Android Debug build does't loads image assets from the react-native assets folder


For Testing and sharing purpose , I created an apk using the following code in Terminal

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

and create apk using

Create debug build:
cd android
./gradlew assembleDebug

This above solution is from stackoverflow that successfully created a good apk file,

But, While i am testing the apk, it doesn't shows the icons from the folder

"react-native-project-name/assets" 

only shows white space instead of icons. tested some solutions but noting resolves this issue.

version

react-native-cli: 2.0.1
react-native: 0.55.4

Solution

  • There might be two cases:

    1-Check ${project}/android/app/src/ res, if imgs not in there, maybe you should manually run this command in project root to copy imgs: 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/.

    2-The issue might be the image size. I had a large local .png and was trying to resize to a small thumbnail and it wouldn't show. iOS handles it, Android didn't.

    https://github.com/facebook/react-native/issues/9451