I have static image in my react-native app accessing via
<Image source={require("../assets/preview-full-img-title-logo@2x.png")} />
in development it is showing well but in production release APK is not showing what can be the reason? I have followed steps mention here.
https://facebook.github.io/react-native/docs/signed-apk-android.html
This is the command that did it for me:
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/
I'm using react-native v0.59.9 with shrinkResources true
configuration.
It makes react-native could not find the assets.
Make sure you do not set shrinkResources
on android build.gradle unless the new version of react-native support it later on.
Verify whether images are in ../res
folder or not ${project}/android/app/src/res
. If not then you need to copy images in that folder. That can be done using following react command
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/
Ideally, this happens in Android when images sizes are larger. Another way to avoid such issues at runtime is to optimize image sizes.
来源:https://stackoverflow.com/questions/38941436/react-native-android-static-image-is-not-showing-in-production-released-apk