Okay, I’ve been struggling for the last two days and this is it. I’m developing my first React Native android app using React Native CLI and using the following Packages:
"dependencies": {
"@react-native-masked-view/masked-view": "^0.2.6",
"@react-navigation/drawer": "^6.3.1",
"@react-navigation/material-bottom-tabs": "^6.1.1",
"@react-navigation/material-top-tabs": "^6.1.1",
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.1.1",
"react": "17.0.2",
"react-native": "0.67.3",
"react-native-gesture-handler": "^2.3.2",
"react-native-immersive": "^2.0.0",
"react-native-linear-gradient": "^2.5.6",
"react-native-material-textinput": "^1.3.0",
"react-native-pager-view": "^5.4.15",
"react-native-paper": "^4.11.2",
"react-native-reanimated": "^2.4.1",
"react-native-safe-area-context": "^4.2.1",
"react-native-screens": "^3.13.1",
"react-native-svg": "^12.3.0",
"react-native-tab-view": "^3.1.1",
"react-native-vector-icons": "^9.1.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"babel-jest": "^26.6.3",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-svg-transformer": "^1.0.0",
"react-test-renderer": "17.0.2"
},
In the Development mode, The App works just fine and smooth. I’m developing the app without any errors. But, When I built the app for production into aab and apk files, the issue arises. If I run the app, whether via npx react-native run-android --variant=release
or installing the app on my physical device, the app just close instantly after opening. Here’s the GitHub Repo Link
Note: I’m developing the app in Windows 10 with the latest Android Studio and all the latest versions of dependencies.
Preview: App on Production Mode
Preview: App on Development Mode
3
Answers
The problem was in my android/app/build.gradle file. I've changed following values:
def enableProguardInReleaseBuilds = false
def enableSeparateBuildPerCPUArchitecture = false
universalApk false
If I keep those unchanged, the builds work perfectly and smoothly. Can anyone please describe the reason?
Please run the app in the simulator with LogCat running and check the error message there. That should give some indication, like this it could be anything. If logcat does not automatically run in your android studio you can open a terminal and run:
This issue can occur due to variations from libs version incompatibilities, missing files and configuration…
In my case it was a missing key in file in:
Info.plist
Try looking at the simulator error log..