This guide is for React Native 0.42.
When working on an app with many static images, I found out that those images were displayed correctly on the emulator, but were blank when testing on a real device. It turns out that those images need to be bundled as assets when running on a device. Google search gave me this SO answer. However, this answer doesn’t work for the RN 0.42 version.
The usage of
react-native bundle command copies the assets to the diretory
android/app/src/main/res/, but it causes the duplicate files issue when running the
./gradlew assembleRelease command. This is because in the newer version of RN, the assets folder is now
So we don’t need the step of using
react-native bundle command at all. Just run
./gradlew assembleRelease and it does all the work for you. Then we can install the release APK using
Some other issues you may encounter and solutions:
Failed to capture snapshot of input files for task ‘bundleReleaseJsAndAssets’ during up-to-date check. java.io.FileNotFoundException: $(rn_project)/.buckd/sock (Operation not supported on socket)
Solution: Delete the
.buckddirectory, see here.