React-native: Release build of Hermes + ProGuard crashes on 0.62.0-rc.5

Created on 9 Mar 2020  路  7Comments  路  Source: facebook/react-native

When building a release version of Android with Hermes and ProGuard enabled, it instantly crashes on 0.62.0-rc.5.

In the log I see the following:

About to load: libhermes.so
libhermes.so not found on /data/data/com.rn062/lib-main
libhermes.so found on /data/app/com.rn062-Fjs_ZyNxAT33Mc4PFvqS7Q==/lib/x86
Not resolving dependencies for libhermes.so

React Native version:

0.62.0-rc.5

Steps To Reproduce

This is tested on Linux (PureOS, basically Debian).

  1. Create a new project npx react-native init RN062 --version 0.62.0-rc.5
  2. Enable Hermes and ProGuard in android/app/build.gradle
  3. Add Hermes exception in android/app/proguard-rules.pro:
    -keep class com.facebook.hermes.unicode.** { *; }
  4. Run npx react-native run-android --variant release. The app will instantly crash.

Expected Results

The app to function properly

Snack, code example, screenshot, or link to a repository:

Crash happens on create react native app template.

Needs Android

Most helpful comment

All 7 comments

It's failing to find com.facebook.jni.NativeRunnable. It appears to work if you add -keep class com.facebook.jni.** { *; }

Yes adding -keep class com.facebook.jni.** { *; }to android/app/proguard-rules.pro fixes the problem for me!

Closing this one as PR got merged in website repo.

Should the new proguard rule have gone into React Native's proguard-rules.pro file so users wouldn't need to add it to their own?

@matt-oakes @Maskedman99 @alloy I created a PR for that https://github.com/facebook/react-native/pull/28571. But I'm not sure if people will be happy if we don't strip this when they don't use hermes

@radko93 I see what you mean, but given that a lot of React Native developers have very limited experience with native tooling like ProGuard, I would suggest making the default as simple as possible. Especially as the issue won't show up until the use creates a release build and runs that, which might not happen until it's been published.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phongyewtong picture phongyewtong  路  3Comments

axelg12 picture axelg12  路  3Comments

jlongster picture jlongster  路  3Comments

anchetaWern picture anchetaWern  路  3Comments

ghost picture ghost  路  3Comments