Proguard启用时React本地应用程序崩溃

6pp0gazn  于 2023-02-24  发布在  React
关注(0)|答案(2)|浏览(125)

我有一个React-Native应用程序在调试时运行良好,但是在发布版本中无法打开。
禁用proguard可以解决这个问题,所以我开始查找每个第三方软件包的安装文档,我的proguard规则看起来很好,遗憾的是我无法检测到哪个软件包造成了这个问题。
我的问题是:* * 如何检测哪个第三方软件包导致此问题**?

依赖项:

{
  "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"
  },
}

保护规则

-keep class com.facebook.hermes.unicode.** { *; }
-keep class com.facebook.jni.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
z0qdvdin

z0qdvdin1#

我遇到了类似的问题,经过一些调试和尝试不同的解决方案。我不得不在file /android/app/ www.example.com中添加所有这些规则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.** {*;}

特别是最后一个是最常见的,大多数人面临的问题。只要添加它,如果你正在使用任何类型的SVG在您的应用程序。

ukqbszuj

ukqbszuj2#

您可以测试发布版本并在控制台中查找错误。
https://reactnative.dev/docs/signed-apk-android#testing-the-release-build-of-your-app

相关问题