React Native Android: Static Image is not showing in production released apk

前端 未结 5 611
攒了一身酷
攒了一身酷 2020-12-16 21:59

I have static image in my react-native app accessing via

  
相关标签:
5条回答
  • 2020-12-16 22:36

    I'm using RN 0.61.2

    As stated by @made-in-moon here this worked for me:

    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/

    0 讨论(0)
  • 2020-12-16 22:39

    For iOS 14 one can also upgrade to the latest version of react-native 0.63.3

    0 讨论(0)
  • 2020-12-16 22:45

    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.

    0 讨论(0)
  • 2020-12-16 22:50

    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/

    take a look at github issue>

    0 讨论(0)
  • 2020-12-16 22:54

    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.

    0 讨论(0)
提交回复
热议问题