如何在Android中捆绑React Native的图像资源? [英] How to bundle images resources of React Native in Android?
本文介绍了如何在Android中捆绑React Native的图像资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用
react-native bundle --entry-file "index.android.js" --platform "android" --bundle-output "./assets/index.android.bundle" --verbose
to打包JS代码包并将其放入资源,它可以工作但本地图像资源无法显示,本地图像资源位于 ./ App / Img /
文件夹中,并用于:
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');
我如何捆绑这些资源文件,以便生成一个正在运行的apk。
How can I bundle this resource files too so that I can generate a single running apk.
推荐答案
我使用 bundle 命令将资源捆绑到android res /文件夹中:
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
然后用gradlew构建:
then build with gradlew:
./gradlew installRelease
这篇关于如何在Android中捆绑React Native的图像资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文