diff --git a/android/build.gradle.kts b/android/build.gradle.kts index f705d223..33d69b72 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -53,7 +53,12 @@ android { } buildTypes.all { signingConfig = signingConfigs.getByName("release") } } - buildTypes { getByName("release") { isMinifyEnabled = false } } + buildTypes { + getByName("release") { + isMinifyEnabled = true + proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro") + } + } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/android/proguard-android-optimize.txt b/android/proguard-android-optimize.txt new file mode 100644 index 00000000..e2095ad6 --- /dev/null +++ b/android/proguard-android-optimize.txt @@ -0,0 +1,36 @@ +-allowaccessmodification +-dontpreverify +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-verbose + +-keepattributes *Annotation* + +-keepclasseswithmembernames class * { + native ; +} + +-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 ; +} + +-keepclasseswithmembers class * { + @androidx.annotation.Keep ; +} + +-keepclasseswithmembers class * { + @androidx.annotation.Keep (...); +} diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 00000000..b69f8dd0 --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1,16 @@ +-keepattributes SourceFile,LineNumberTable +-keepattributes RuntimeVisibleAnnotations, + RuntimeVisibleParameterAnnotations, + RuntimeVisibleTypeAnnotations, + AnnotationDefault +-renamesourcefileattribute SourceFile +# Retain the generic signature of retrofit2.Call until added to Retrofit. +# Issue: https://github.com/square/retrofit/issues/3580. +# Pull request: https://github.com/square/retrofit/pull/3579. +-keep,allowobfuscation,allowshrinking class retrofit2.Call + +# Retain annotation default values for all annotations. +# Required until R8 version >= 3.1.12-dev (expected in AGP 7.1.0-alpha4). +-keep,allowobfuscation,allowshrinking @interface * + +-keep,allowobfuscation,allowshrinking class dev.msfjarvis.claw.android.** { *; } diff --git a/build.gradle.kts b/build.gradle.kts index 519600ff..eafeb4e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,12 +7,17 @@ buildscript { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") content { includeModule("me.amanjeet.daggertrack", "dagger-track") } } + maven { + url = uri("https://storage.googleapis.com/r8-releases/raw") + content { includeModule("com.android.tools", "r8") } + } } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") classpath("com.android.tools.build:gradle:7.1.0-alpha02") classpath("com.diffplug.spotless:spotless-plugin-gradle:5.14.0") classpath("com.google.dagger:hilt-android-gradle-plugin:2.37") + classpath("com.android.tools:r8:3.1.13-dev") classpath("me.amanjeet.daggertrack:dagger-track:1.0.6-SNAPSHOT") } }