App crash when trying to load react native component in release mode
See original GitHub issueDescription
I am trying to add a react native component in my native Android app. It work fine when I am using debug build type. But when I use release build type with minifyEnabled true and shrinkResources true. Try to load react native component app crash with below error.
I/art: Thread[1,tid=7118,Native,Thread*=0xadd8b400,peer=0x73df36f0,"main"] recursive attempt to load library "/data/app/{package name}-1/lib/x86/libfb.so"
Reproduction
Integrate a react native component in native Android app. Enable proguard and use minifyEnabled true and shrinkResources true. Try to load the component app will crash with above mentioned error.
Solution
Please let me know how can I fix this issue. Please find below proguard entries.
React Native
Keep our interfaces so they can be used by other ProGuard rules.
See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class * -keep @com.facebook.common.internal.DoNotStrip class * -keepclassmembers class * { @com.facebook.proguard.annotations.DoNotStrip *; @com.facebook.common.internal.DoNotStrip *; }
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { void set*(**); *** get(); }
-keep class * extends com.facebook.react.bridge.JavaScriptModule { ; } -keep class * extends com.facebook.react.bridge.NativeModule { ; } -keepclassmembers,includedescriptorclasses class * { native <methods>; } -keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; } -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; } -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; } -dontwarn com.facebook.react. -dontwarn android.text.StaticLayout
okhttp
-keep class com.squareup.okhttp.** { ; } -keep interface com.squareup.okhttp.* { ; } -dontwarn com.squareup.okhttp.*
okio
-keep class sun.misc.Unsafe { ; } -dontwarn java.nio.file. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement -dontwarn okio.**
stetho
-dontwarn com.facebook.stetho.**
Additional Information
- React Native version: “react”: “^15.4.1”, “react-native”: “0.42.0”
- Platform: Android
- Operating System: MacOS
- Dev tools: Android Studio 2.3
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)

Top Related StackOverflow Question
react-native app crashes on android phone. App gets hanged on listview scrolling.
“react”: “16.0.0-alpha.6” “react-native”: “0.43.3”
@alloy, thanks you very much for your reply. I will try to provide sample APK and also try to post the same issue on StackOverflow.