How to link React Native image resources in Android?

I use

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

to pack a package of JS code and put it in assets, it works, but local image resources cannot be displayed, local image resources are located in a folder ./App/Img/and will be used in:

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

How can I link these resource files so that I can generate one running apk.

+4
source share
1 answer

I use the bundle command to pool resources in 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
+3
source

Source: https://habr.com/ru/post/1629985/


All Articles