This issue relates to Android.
We have recently migrated our react-native project from Expo to bare workflow. We have an issue however whereby images are not loading when running the built apk file.
When debugging on an emulator or device using react-native android
everything works fine. However on a built apk images simply do not appear.
Our build is being conducted as follows
react-native bundle --platform android / --dev false / --entry-file index.js --bundle-output android/app/src/main/assets/app.bundle --assets-dest android/app/src/main/resandroid/gradlew -p android cleanandroid/gradlew -p android assembleRelease
I can see that the first step bundles our images into the following directory
android/app/src/main/res/drawable-mdpi
The project structure looks like this
index.jsApp.js ios/ android/ app/ assets/ package.json images/ image01.png image02.png screens/ MyScreen.js
app/assets/package.json
to allow us to avoid absolute paths contains
{ "name": "@assets"}
and within MyScreen.js we have, within the render()
method
<Image source={require('@assets/images/image01.png')} />
Unpacking the built apk (app-release.apk
) I can see that the images are referenced in the MANIFEST.MF
file
/release/app-release/META-INF
like so
Name: res/drawable-mdpi-v4/app_assets_images_image01.pngSHA-256-Digest: [BLAH]Name: res/drawable-mdpi-v4/app_assets_images_image02.pngSHA-256-Digest: [BLAH]
within release/app-release/res/drawable-mdpi-v4
the images are present and accounted for having the same name as the manifest.
So I am utterly confused as to why they do not display when running the apk on a device.
This is not an uncommon issue and there are several other Stack Overflow issues along this vein, however I have gone through all of them and none of the suggested solutions work for us.
Gradle version=5.6.3
RN version=61.5