Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native app crashing on Proguard Enable

I have a React-Native app which is working perfectly fine on debug. But the app doesn't open on release build.

Disabling proguard fixes the issue. So I started looking installation documentation for each third party package installed and my proguard rules seemed fine. Sadly I couldn't detect which package is creating the issue.

My question is : how can I detect which third party package is causing this issue ?

Dependencies :

{
  "dependencies": {
    "@gorhom/bottom-sheet": "^4.1.5",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/material-top-tabs": "^6.0.6",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/stack": "^6.0.11",
    "ky": "^0.28.7",
    "react": "^17.0.2",
    "react-native": "0.66.4",
    "react-native-android-location-enabler": "^1.2.2",
    "react-native-auto-height-image": "^3.2.4",
    "react-native-geolocation-service": "^5.3.0-beta.1",
    "react-native-gesture-handler": "^2.1.0",
    "react-native-image-crop-picker": "^0.36.0",
    "react-native-immersive-mode": "^2.0.0",
    "react-native-maps": "^0.29.4",
    "react-native-mmkv": "^1.5.4",
    "react-native-pager-view": "^5.4.9",
    "react-native-paper": "^4.11.1",
    "react-native-reanimated": "2.3.1",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.10.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-vector-icons": "^9.0.0",
    "react-native-version-check": "^3.4.2",
    "react-query": "^3.34.5"
  },
}

Proguard Rules

-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
like image 274
ArnabXD Avatar asked Sep 12 '25 21:09

ArnabXD


1 Answers

I faced similar problem and after some debugging and trying different solutions. I had to add all these rules in file /android/app/proguard-rules.pro

-keep class com.swmansion.reanimated.** { *; }
-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
-keep public class com.horcrux.svg.** {*;}

Especially last one is most common that most people face problem with. Just add it if you are using any kind SVGs in your app.

like image 130
Abdullah Avatar answered Sep 14 '25 13:09

Abdullah