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
This is tested on Linux (PureOS, basically Debian).
npx react-native init RN062 --version 0.62.0-rc.5android/app/build.gradleandroid/app/proguard-rules.pro:-keep class com.facebook.hermes.unicode.** { *; }npx react-native run-android --variant release. The app will instantly crash.The app to function properly
Crash happens on create react native app template.
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!
Opened a PR for the website: https://github.com/facebook/react-native-website/pull/1715
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.
Most helpful comment
Opened a PR for the website: https://github.com/facebook/react-native-website/pull/1715