Code obfuscation hides function and class names in your compiled Dart code, making it difficult for an attacker to reverse engineer your proprietary app. This can be enabled with the --obfuscate
option, which is required to be paired with --split-debug-info
to generate a symbol map.
As of flutter 1.16.2, the information below is out of date. Only use this if you're on an earlier version of Flutter. If you are using Flutter 1.16.2 or later, please refer to Obfuscating Dart code on flutter.dev.
Add the following line to <ProjectRoot>/android/gradle.properties
:
extra-gen-snapshot-options=--obfuscate
For information on obfuscating the Android host, see Enabling Proguard in Preparing an Android App for Release.
Add the following flag to the build aot
call in the <FlutterRoot>/packages/flutter_tools/bin/xcode_backend.sh
file:
${extra_gen_snapshot_options_or_none}
Define this flag as follows:
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
In <ProjectRoot>/ios/Flutter/Release.xcconfig
, add the following line:
EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate