React Native Crash Undefined is not an object (Evaluating ‘Sn[e]’)

React Native Crash Undefined is not an object (Evaluating ‘Sn[e]’)

Any one facing react native build issue? I am trying to generate debug build but its crashing when the app is launched . The exception has no useful information. I was facing the same issue with

sudo react-native run-android

 

But that got resolved after upgrading RN from 0.48 to 0.55(latest Stable Version). But the crash remain same for the apk generated using

sudo gradlew assembleDebug

The crash is similar to https://github.com/facebook/react-native/issues/16745

please see screenshot

ReactNative Undefined Not an object evaluating
ReactNative Undefined Not an object evaluating

Solution: Generating React Native Android Release and Debug Builds

1. If any one facing issue with generating ReactNative android build then do not forget to follow below steps

2. Update your key store details as given here

3. Then explicitly bundle the assets using below command

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ 

4. Generate the build using gradle

cd android && ./gradlew assembleRelease

Note: for release build I am facing another issue as follows

Error in Release build :

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of input files for task ‘bundleReleaseJsAndAssets’ property ‘$1’ during up-to-date check.
> Failed to create MD5 hash for file ‘/Development/SourceCode/MobApp/testApp/root-state/sock’.

* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

To generate debug build

cd android && ./gradlew assembleDebug

 

Credits : SO Post