'Exceptions is not processed very well when a release buid is generated in React Native in Android

The problem is very simple, I have a part in my React Native project where I throw an Error, for example:

...
throw new Error('Example error');
...

When I normally execute npx react-native run-android to develop and debug I see the error correctly but when is in release mode npx react-native run-android --variant=release the error becomes weird.

Something like:

{
 "name": "v",
 "line": 1231,
 "column": 331,
 "sourceURL": "index.android.bundle"
}

Seems like if in the compilation to the Android .apk, something goes wrong with the errors.

Some clue for this problem? Thanks!



Solution 1:[1]

Your code gets transpiled, optimized, and minified in release builds. That's why they run faster than debug builds. The tradeoff is this, that the code becomes obfuscated to humans. If you want more details in your release builds, it's best to be more explicit with your errors.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Abe