mirror of
https://github.com/status-im/react-native.git
synced 2025-01-18 13:31:18 +00:00
c2fd54fcb2
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
71 lines
2.6 KiB
Prolog
71 lines
2.6 KiB
Prolog
# Add project specific ProGuard rules here.
|
|
# By default, the flags in this file are appended to flags specified
|
|
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
|
|
# You can edit the include path and order by changing the proguardFiles
|
|
# directive in build.gradle.
|
|
#
|
|
# For more details, see
|
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
|
|
# Add any project specific keep options here:
|
|
|
|
# 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 *;
|
|
#}
|
|
|
|
# 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
|
|
|
|
# React Native
|
|
|
|
# Keep our interfaces so they can be used by other ProGuard rules.
|
|
# See http://sourceforge.net/p/proguard/bugs/466/
|
|
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
|
|
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
|
|
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
|
|
|
|
# Do not strip any method/class that is annotated with @DoNotStrip
|
|
-keep @com.facebook.proguard.annotations.DoNotStrip class *
|
|
-keep @com.facebook.common.internal.DoNotStrip class *
|
|
-keepclassmembers class * {
|
|
@com.facebook.proguard.annotations.DoNotStrip *;
|
|
@com.facebook.common.internal.DoNotStrip *;
|
|
}
|
|
|
|
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
|
|
void set*(***);
|
|
*** get*();
|
|
}
|
|
|
|
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
|
|
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
|
|
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
|
|
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
|
|
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
|
|
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
|
|
|
|
-dontwarn com.facebook.react.**
|
|
|
|
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
|
|
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
|
|
-dontwarn android.text.StaticLayout
|
|
|
|
# okhttp
|
|
|
|
-keepattributes Signature
|
|
-keepattributes *Annotation*
|
|
-keep class okhttp3.** { *; }
|
|
-keep interface okhttp3.** { *; }
|
|
-dontwarn okhttp3.**
|
|
|
|
# okio
|
|
|
|
-keep class sun.misc.Unsafe { *; }
|
|
-dontwarn java.nio.file.*
|
|
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
|
|
-dontwarn okio.**
|