Description
Description
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 ; }
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; }
-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