APK errors

Hermes: JS error only in release

Error text

E/ReactNativeJS: TypeError: undefined is not an object (evaluating 'a.b.c')
Hermes: Execution of bytecode failed in release build only

Cause

An app that works in debug breaks in release. Release minifies code, disables __DEV__ and runs Hermes bytecode.

Step-by-step fix

  1. Pull the real error text with adb logcat.
  2. Create a bundle with --dev false and reproduce the same error.
  3. Check code that depends on debug-only things (__DEV__, dev menu).
  4. Update the suspect library; you need a Hermes-compatible version.
  5. Map the error line back to real code with the source map.

Example commands

adb logcat -s ReactNativeJS:V ReactNative:V
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output /tmp/i.bundle --sourcemap-output /tmp/i.map
cd android && ./gradlew assembleRelease

How to prevent it

Test the release APK on a real phone every week, not just on the last day.

Author and license: Nibras Code