如何通过本机启用Proguard?

问题描述 投票:0回答:1

我想减小我的APK大小我关注了这些https://facebook.github.io/react-native/docs/signed-apk-android并运行./gradlew bundleRelease而不是assembleRelease但是我得到了错误

对于任务':app:transformClassesAndResourcesWithProguardForRelease,执行失败。作业失败,

所以我该如何解决,我是Google,但问题仍然存在!但是如果没有Enable Proguard,它会很好地工作,我得到了(Aab&.Apk)这样的解决方法!

我认为此文件存在问题,但我不知道该如何配置!

proguard-rules.pro


# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

Package.json

{
  "name": "APP_NAME",
  "version": "1.12.3",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.4.2",
    "@turf/distance": "^6.0.1",
    "@turf/helpers": "^6.1.4",
    "@turf/invariant": "^6.1.2",
    "@turf/turf": "^5.1.6",
    "firebase-admin": "^8.1.0",
    "firebase-functions": "^3.0.1",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "react": "16.8.6",
    "react-moment": "^0.9.2",
    "react-native": "0.59.8",
    "react-native-app-intro-slider": "^3.0.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-fcm": "^16.2.4",
    "react-native-firebase": "5.3.1",
    "react-native-gesture-handler": "1.2.1",
    "react-native-image-picker": "^0.28.0",
    "react-native-linear-gradient": "^2.5.4",
    "react-native-maps": "^0.24.2",
    "react-native-stars": "^1.1.5",
    "react-native-svg": "^9.3.3",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "3.11.0"
  },
  "devDependencies": {
    "@babel/parser": "^7.4.4",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "24.8.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.54.1",
    "react-devtools": "^3.6.1",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}
javascript android react-native react-native-android
1个回答
0
投票

如果您要启用Proguard(在android / app / build.gradle中为minifyEnabled true,则需要更新Proguard规则。

in(android / app / proguard-rules.pro)添加以下行:

-keep class io.invertase.firebase.** { *; }
-dontwarn io.invertase.firebase.**

有关更多信息,您可以在步骤4之前检查https://rnfirebase.io/docs/v4.3.x/installation/android

© www.soinside.com 2019 - 2024. All rights reserved.