gpt4 book ai didi

javascript - 如何使用 native react 启用 Proguard?

转载 作者:行者123 更新时间:2023-12-05 00:10:34 24 4
gpt4 key购买 nike

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

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. Job failed,



那么我该如何解决它,我是谷歌它,但问题仍然存在!
但是如果没有 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 *;
#}


包.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"
}
}

最佳答案

如果您希望在您的应用程序中使用“react-native-firebase”包时启用 Proguard(在 android/app/build.gradle 中为 minifyEnabled true),您需要更新您的 proguard 规则。

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

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

更多信息可以查看 https://rnfirebase.io/docs/v5.x.x/installation/android就在第 4 步之前。

如果它不起作用,您必须转到您使用的其他软件包的文档,并且必须查找其他首选项以使其设置与启用的 Proguard 兼容。

关于javascript - 如何使用 native react 启用 Proguard?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57313737/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com