如何混淆Flutter应用程序? [英] How to obfuscate Flutter apps?
问题描述
Flutter的Wiki 提到混淆是一种选择
但是, flutter build 命令没有相关选项-请参阅:
flutter帮助-v构建apk
Flutter's wiki mentions obfuscation is an opt-in in release mode.
And yet, the flutter build command has no relevant option - see:
flutter help -v build apk
我在这里丢失了什么吗?
他们是否将混淆设置为默认设置?
混淆甚至与颤动相关吗?
Am I missing something here?
Did they make obfuscation the default?
Is obfuscation even relevant for flutter?
对此,任何指针都将不胜感激。
Any pointers on this would be very appreciated.
推荐答案
需要混淆-扑扑的应用程序知道其功能名称,可以使用Dart的StackTrace类显示该名称。迷惑性有未测试的支持。要启用它:
Obfuscation is needed - a flutter app knows its function names, which can be shown using Dart's StackTrace class. There's under-tested support for obfuscation. To enable it:
对于Android :
添加到文件 [ProjectRoot] /android/gradle.properties
:
extra-gen-snapshot-options=--obfuscate
对于iOS:
首先,编辑 [FlutterRoot] /packages/flutter_tools/bin/xcode_backend.sh
:
找到 build aot
调用,并添加一个标志,
For iOS:
First, edit [FlutterRoot]/packages/flutter_tools/bin/xcode_backend.sh
:
Locate the build aot
call, and add a flag to it,
${extra_gen_snapshot_options_or_none}
定义为:
local extra_gen_snapshot_options_or_none=""
if [[ -n "$EXTRA_GEN_SNAPSHOT_OPTIONS" ]]; then
extra_gen_snapshot_options_or_none="--extra-gen-snapshot-options=$EXTRA_GEN_SNAPSHOT_OPTIONS"
fi
要应用更改,请在[FlutterRoot]中运行
To apply your changes, in [FlutterRoot], run
git commit -am "Enable obfuscation on iOS"
flutter
(在提交重建颤振工具后运行 flutter。)
(Running "flutter" after the commit rebuilds flutter tools.)
下一步,在您的项目中,将以下内容添加到 [ProjectRoot] /ios/Flutter/Release.xcconfig
文件:
Next, in your project, add following to [ProjectRoot]/ios/Flutter/Release.xcconfig
file:
EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate
PS:没有尝试过 https://github.com/dart-lang/sdk/issues/30524
再一次,混淆 isn如@mraleph所述,
这篇关于如何混淆Flutter应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!