我用
react-native bundle --entry-file "index.android.js" --platform "android" --bundle-output "./assets/index.android.bundle" --verbose
打包JS代码包并将其放入资源,它可以工作,但不能显示本地图像资源,本地图像资源位于./App/Img/
文件夹中,并可用于:
const icon1 = require('./App/Img/slider.png');
我如何捆绑此资源文件,以便生成一个正在运行的apk。
答案 0 :(得分:3)
我使用 bundle 命令将资源捆绑到android res /文件夹中:
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构建:
./gradlew installRelease