From c2fd54fcb287bb635f93d1de15bafecbeb282264 Mon Sep 17 00:00:00 2001 From: Jamie Lynch Date: Fri, 16 Mar 2018 18:21:59 -0700 Subject: [PATCH] Enable obfuscation in ProGuard rules by default Summary: This PR enables obfuscation in ProGuard by default when creating a new project, and documents how developers can turn obfuscation off if they desire. The ProGuard phase is currently disabled by default. If a developer wanted to enable ProGuard, the first thing they would see is the following line in their build.gradle file: `def enableProguardInReleaseBuilds = false` It's really easy to assume that enabling this flag will setup code shrinking and obfuscation, as this is the default behaviour for a completely native Android Studio project, or when running ProGuard from the command line directly. However, the generated ProGuard rules override the default behaviour. Without visually inspecting the rules file, searching for a mapping file, or analyzing the Dex file classes, this isn't immediately obvious, as the APK will be smaller, and gradle will show the Proguard task as completing. Personally I find this confusing and really wasn't expecting for obfuscation to be disabled - most Android Error Reporting services allow deobfuscation of stacktraces via mapping files. 1. Create a new project using `react-native init MyProject` 2. Observe that `-dontobfuscate` is commented out [ANDROID] [MINOR] [ProGuard] - Enables obfuscation by default in newly created projects Closes https://github.com/facebook/react-native/pull/17754 Differential Revision: D7251680 Pulled By: hramos fbshipit-source-id: cf9ca7753640643377a51daa4fa9065516197340 --- local-cli/templates/HelloWorld/android/app/proguard-rules.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local-cli/templates/HelloWorld/android/app/proguard-rules.pro b/local-cli/templates/HelloWorld/android/app/proguard-rules.pro index 6e8516c8d..d8ec99250 100644 --- a/local-cli/templates/HelloWorld/android/app/proguard-rules.pro +++ b/local-cli/templates/HelloWorld/android/app/proguard-rules.pro @@ -18,7 +18,7 @@ # Disabling obfuscation is useful if you collect stack traces from production crashes # (unless you are using a system that supports de-obfuscate the stack traces). --dontobfuscate +# -dontobfuscate # React Native