如何在 Flutter 发布的 apk 中禁用代码混淆?
How to disable code obfuscation in Flutter release apk?
我利用 agora-rtc-engine (https://pub.dev/packages/agora_rtc_engine)
在 Flutter 中构建了一个视频会议应用程序
我的应用程序在调试版本上运行完美,但每当我尝试在应用程序的发布版本中加入 room/video 会议时它就会崩溃。库的 pub-dev 页面提到这是由于 Flutter 的代码混淆造成的。他们展示的防止崩溃的方法已经过时 (proguard.rules)。那么,我现在该如何修复它?
这里是完整的源代码:https://github.com/CodeSarthak/Vartalap
感谢任何帮助。非常感谢!
通常情况下,您只需要添加一个设置很少的文件:D
- 创建混淆规则来定义要阻止的内容
这是对我有用的方法,根据您的应用程序,您可能需要添加更多特定于您的解决方案的内容。 :D
- 创建 ProGuard 文件
代码:
创建文件:proguard-rules.pro
## Flutter wrapper
-keepattributes Signature
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.google.firebase.** { *; }
-keepattributes JavascriptInterface
-keepattributes Annotation
-dontwarn com.razorpay.**
-keep class com.razorpay.** { *; }
-optimizations !method/inlining/
-keepclasseswithmembers class * {public void onPayment*(...);}
-keepclassmembers class * {@android.webkit.JavascriptInterface ;}
-keepclassmembers class com.yourpackagehere.models.** { *; }
-dontwarn io.flutter.embedding.**
- 并将其添加到应用级别 gradle 文件
代码:
里面build.gradle
buildTypes {
release {
shrinkResources false
signingConfig signingConfigs.release
minifyEnabled false
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
希望对您有所帮助:D
我利用 agora-rtc-engine (https://pub.dev/packages/agora_rtc_engine)
在 Flutter 中构建了一个视频会议应用程序我的应用程序在调试版本上运行完美,但每当我尝试在应用程序的发布版本中加入 room/video 会议时它就会崩溃。库的 pub-dev 页面提到这是由于 Flutter 的代码混淆造成的。他们展示的防止崩溃的方法已经过时 (proguard.rules)。那么,我现在该如何修复它?
这里是完整的源代码:https://github.com/CodeSarthak/Vartalap
感谢任何帮助。非常感谢!
通常情况下,您只需要添加一个设置很少的文件:D
- 创建混淆规则来定义要阻止的内容 这是对我有用的方法,根据您的应用程序,您可能需要添加更多特定于您的解决方案的内容。 :D
- 创建 ProGuard 文件
代码: 创建文件:proguard-rules.pro
## Flutter wrapper
-keepattributes Signature
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.google.firebase.** { *; }
-keepattributes JavascriptInterface
-keepattributes Annotation
-dontwarn com.razorpay.**
-keep class com.razorpay.** { *; }
-optimizations !method/inlining/
-keepclasseswithmembers class * {public void onPayment*(...);}
-keepclassmembers class * {@android.webkit.JavascriptInterface ;}
-keepclassmembers class com.yourpackagehere.models.** { *; }
-dontwarn io.flutter.embedding.**
- 并将其添加到应用级别 gradle 文件
代码:
里面build.gradle
buildTypes {
release {
shrinkResources false
signingConfig signingConfigs.release
minifyEnabled false
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
希望对您有所帮助:D