summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-03-29 10:50:47 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-03-29 10:52:54 +0530
commitb3bb7c694b55fd2c65970abf528a25a38239385e (patch)
tree5da353c6b79f41a4e280f4e7d5c0cfb6cb03fcc2
parent456a74db05d5662ff8c2623570809f782329f217 (diff)
build: Improve R8 rules and enable aggressive optimization modes
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r--gradle.properties14
-rw-r--r--ui/build.gradle2
-rw-r--r--ui/proguard-android-optimize.txt36
3 files changed, 51 insertions, 1 deletions
diff --git a/gradle.properties b/gradle.properties
index 9e6fce10..8375129e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -17,3 +17,17 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
+
+# R8 Full mode
+android.enableR8.fullMode=true
+
+# https://jakewharton.com/increased-accuracy-of-aapt2-keep-rules/
+android.useMinimalKeepRules=true
+
+# Enable rudimentary R class namespacing where each library only contains
+# references to the resources it declares instead of declarations plus all
+# transitive dependency references.
+android.namespacedRClass=true
+
+# Suppress warnings for some features that aren't yet stabilized
+android.suppressUnsupportedOptionWarnings=android.enableR8.fullMode,android.useMinimalKeepRules,android.namespacedRClass,android.suppressUnsupportedOptionWarnings
diff --git a/ui/build.gradle b/ui/build.gradle
index e1d99604..2ebfc1af 100644
--- a/ui/build.gradle
+++ b/ui/build.gradle
@@ -57,7 +57,7 @@ android {
}
}
minifyEnabled true
- proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
+ proguardFiles "proguard-android-optimize.txt", "proguard-rules.pro"
}
debug {
applicationIdSuffix ".debug"
diff --git a/ui/proguard-android-optimize.txt b/ui/proguard-android-optimize.txt
new file mode 100644
index 00000000..e2095ad6
--- /dev/null
+++ b/ui/proguard-android-optimize.txt
@@ -0,0 +1,36 @@
+-allowaccessmodification
+-dontpreverify
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-verbose
+
+-keepattributes *Annotation*
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keepclassmembers class * implements android.os.Parcelable {
+ public static final ** CREATOR;
+}
+
+-keep class androidx.annotation.Keep
+
+-keep @androidx.annotation.Keep class * {*;}
+
+-keepclasseswithmembers class * {
+ @androidx.annotation.Keep <methods>;
+}
+
+-keepclasseswithmembers class * {
+ @androidx.annotation.Keep <fields>;
+}
+
+-keepclasseswithmembers class * {
+ @androidx.annotation.Keep <init>(...);
+}