How to bundle images resources of React Native in

2019-03-16 17:41发布

I use

react-native bundle --entry-file "index.android.js" --platform "android" --bundle-output "./assets/index.android.bundle" --verbose

to package the JS code bundle and put it into assets, it works but the local Image resources can't be displayed, the local image resources located in ./App/Img/ folder, and be used in:

const icon1 = require('./App/Img/slider.png');

How can I bundle this resource files too so that I can generate a single running apk.

1条回答
手持菜刀,她持情操
2楼-- · 2019-03-16 18:17

I use the bundle command to bundle resources into android res/ folder:

    echo "START bundle for android normal resources release"
    react-native bundle \
    --platform android \
    --entry-file index.android.js \
    --bundle-output android/app/src/main/assets/index.android.bundle \
    --assets-dest  android/app/src/main/res/ \
    --dev false

then build with gradlew:

./gradlew installRelease
查看更多
登录 后发表回答