I encountered an issue while trying to install the Release version of my application. In order to test both the debug and release versions on my physical and virtual devices, I utilized the following commands: ./gradlew assembleDebug, ./gradlew assembleRelease, ./gradlew bundleRelease.
When testing the debug version using npx react-native run-android --variant=debug, everything worked perfectly on both my virtual and physical devices. However, when attempting to test the release version with npx react-native run-android --variant=release, the application was installed but failed to open.
I have attached screenshots of the console messages at startup (view here) and on completion (view here). Additionally, I have included the specifications being used (view here).
To troubleshoot this issue, I followed these steps:
- Navigate to the project directory and run cd android.
- Clean by executing ./gradlew clean.
- Return to the project directory.
- Execute npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ in the terminal.
- In the android directory, run:
- To build the app in debug mode, use ./gradlew assembleDebug.
- To build the app in release mode, use ./gradlew assembleRelease.
- If you want to create a Bundle release, execute ./gradle bundleRelease.
- Finally, locate the built files at the following paths:
- For debug: android/app/build/outputs/apk/debug/app-debug.apk.
- For release: android/app/build/outputs/apk/release/app-release.apk.
- For production: android/app/release/app-release.abb.
For more information, refer to these resources: Stack Overflow, React Native Documentation.