From d9e272f3baa6ce89228a2221c434de49db7d9ee6 Mon Sep 17 00:00:00 2001 From: MUEDSA <7676275+muedsa@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:11:54 +0800 Subject: [PATCH] update: enabled minify build for release --- app/build.gradle.kts | 7 +++-- app/proguard-rules.pro | 62 +++++++++++++++++++++++++++++++++++++-- gradle/libs.versions.toml | 2 +- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9344603..eb942b0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.archivesName import org.jetbrains.kotlin.incremental.createDirectory import java.io.FileInputStream import java.util.Properties @@ -44,7 +45,7 @@ android { targetSdk = 34 versionCode = 2 versionName = "0.0.1-alpha02" - setProperty("archivesBaseName", "AGETV-$versionName") + archivesName = "AGETV" } signingConfigs { @@ -67,6 +68,7 @@ android { buildTypes { debug { isMinifyEnabled = false + isShrinkResources = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" @@ -75,7 +77,8 @@ android { } release { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6b5d98f..11895e0 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -14,16 +14,72 @@ # Uncomment this to preserve the line number information for # debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +-keepattributes SourceFile,LineNumberTable # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile +-renamesourcefileattribute SourceFile + +# akdanmaku gdx -dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication -dontwarn com.badlogic.gdx.utils.GdxBuild -dontwarn com.badlogic.gdx.jnigen.BuildTarget* -dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild # Required if using Gdx-Controllers extension -#-keep class com.badlogic.gdx.controllers.android.AndroidControllers \ No newline at end of file +#-keep class com.badlogic.gdx.controllers.android.AndroidControllers + +# akdanmaku +-keep class com.kuaishou.akdanmaku.** { *; } + +# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and +# EnclosingMethod is required to use InnerClasses. +-keepattributes Signature, InnerClasses, EnclosingMethod + +# Retrofit does reflection on method and parameter annotations. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# Keep annotation default values (e.g., retrofit2.http.Field.encoded). +-keepattributes AnnotationDefault + +# Retain service method parameters when optimizing. +-keepclassmembers,allowshrinking,allowobfuscation interface * { + @retrofit2.http.* ; +} + +# Ignore annotation used for build tooling. +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement + +# Ignore JSR 305 annotations for embedding nullability information. +-dontwarn javax.annotation.** + +# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. +-dontwarn kotlin.Unit + +# Top-level functions that can only be used by Kotlin. +-dontwarn retrofit2.KotlinExtensions +-dontwarn retrofit2.KotlinExtensions$* + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> + +# Keep inherited services. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface * extends <1> + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation + +# R8 full mode strips generic signatures from return types if not kept. +-if interface * { @retrofit2.http.* public *** *(...); } +-keep,allowoptimization,allowshrinking,allowobfuscation class <3> + +# With R8 full mode generic signatures are stripped for classes that are not kept. +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions. \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7e5eae2..01544b0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.3.0-alpha14" +agp = "8.3.0-alpha15" kotlin = "1.9.20" ksp = "1.9.21-1.0.15" core-ktx = "1.12.0"