From 519c75d5f3dc86a49489acdf5f24c211fac79af3 Mon Sep 17 00:00:00 2001 From: oungsi2000 Date: Fri, 21 Aug 2026 02:39:33 +0900 Subject: [PATCH] =?UTF-8?q?build:=20=EC=95=B1=20=EB=A6=B4=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=20=EB=B9=8C=EB=93=9C=20=EC=B5=9C=EC=A0=81=ED=99=94(R8?= =?UTF-8?q?)=20=ED=99=9C=EC=84=B1=ED=99=94=20=EB=B0=8F=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=B8=8C=EB=9F=AC=EB=A6=AC=EB=B3=84=20ProGuard=20?= =?UTF-8?q?=EA=B7=9C=EC=B9=99=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 코드 최적화 및 리소스 축소를 활성화하고, 사용 중인 외부 라이브러리(Kakao SDK, Ktor, kotlinx.serialization 등)의 정상 동작을 위한 ProGuard 규칙을 대폭 업데이트합니다. - `build.gradle.kts`: `isMinifyEnabled` 및 `isShrinkResources`를 `true`로 설정하여 릴리스 빌드 시 코드 난독화 및 리소스 축소 적용 - `proguard-rules.pro`: - 리플렉션 및 제네릭 처리를 위한 공통 속성(`Signature`, `Annotations` 등) 유지 설정 추가 - **Kakao SDK**: SDK 내부 클래스 및 리플렉션을 사용하는 Gson 관련 직렬화 모델의 난독화 제외 규칙 추가 - **Ktor & OkHttp**: 엔진 탐색을 위한 `ServiceLoader` 경로 및 안드로이드 미지원 클래스에 대한 경고 무시 처리 - **kotlinx.serialization**: `@Serializable` 어노테이션이 적용된 클래스의 `Companion` 객체와 `serializer()` 메서드가 삭제되지 않도록 공식 권장 규칙 적용 - 기존의 불필요하거나 중복된 Retrofit 관련 규칙 정리 및 주석을 통한 가독성 개선 --- app/build.gradle.kts | 3 +- app/proguard-rules.pro | 89 ++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8f6e4d24..8c8cc2c7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -45,7 +45,8 @@ android { manifestPlaceholders["KAKAO_APP_KEY"] = kakaoKey manifestPlaceholders["APP_LINK_HOST"] = appLinkHost - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 1e97e068..b0a14542 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -20,34 +20,73 @@ # hide the original source file name. #-renamesourcefileattribute SourceFile -# Retrofit +# ───────────────────────────────────────────── +# 공통: 리플렉션/제네릭 기반 라이브러리들이 필요로 하는 속성 +# (Kakao SDK 내부 Retrofit+Gson, kotlinx.serialization 모두 공통으로 사용) +# ───────────────────────────────────────────── -keepattributes Signature, InnerClasses, EnclosingMethod -keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations -keepattributes AnnotationDefault --keepclassmembers,allowshrinking,allowobfuscation interface * { - @retrofit2.http.* ; -} +# ───────────────────────────────────────────── +# Kakao SDK +# 카카오 SDK는 내부적으로 Retrofit + Gson을 번들링해서 씀. +# 모델 클래스가 리플렉션으로 필드에 접근하므로 난독화/축소에서 제외. +# ───────────────────────────────────────────── +-keep class com.kakao.sdk.** { *; } +-keep class * extends com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer --dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement +-dontwarn org.slf4j.** +-dontwarn org.bouncycastle.jsse.** +-dontwarn org.conscrypt.** +-dontwarn org.openjsse.** -dontwarn javax.annotation.** --dontwarn kotlin.Unit --dontwarn retrofit2.KotlinExtensions --dontwarn retrofit2.KotlinExtensions$* - -# suspend 함수 반환 타입 유지 --if interface * { @retrofit2.http.* ; } --keep,allowobfuscation interface <1> - --if interface * { @retrofit2.http.* ; } --keep,allowobfuscation interface * extends <1> - -# Retrofit이 사용하는 제네릭 타입 --keep,allowobfuscation,allowshrinking class retrofit2.Response --keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation --keep,allowobfuscation,allowshrinking interface retrofit2.Call --keep,allowobfuscation,allowshrinking class retrofit2.Response --keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation - --if interface * { @retrofit2.http.* ; } --keep,allowobfuscation interface <1> \ No newline at end of file + +# ───────────────────────────────────────────── +# OkHttp / Okio (Ktor의 OkHttp 엔진이 사용) +# 데스크톱 전용 TLS 프로바이더 감지 코드가 참조하지만 안드로이드엔 없는 클래스들. +# ───────────────────────────────────────────── +-dontwarn okhttp3.internal.platform.** +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement + +# ───────────────────────────────────────────── +# Ktor +# 클라이언트 엔진(OkHttp)을 리플렉션 기반 ServiceLoader로 찾기 때문에 keep 필요. +# ───────────────────────────────────────────── +-keep class io.ktor.** { *; } +-keep interface io.ktor.** { *; } +-dontwarn io.ktor.** + +# ───────────────────────────────────────────── +# kotlinx.serialization +# 공식 권장 규칙(https://github.com/Kotlin/kotlinx.serialization#android) — +# @Serializable 클래스의 Companion/serializer()가 리플렉션처럼 조회되는 경로를 보존. +# ───────────────────────────────────────────── +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} + +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <2>$* { + kotlinx.serialization.KSerializer serializer(...); +} + +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} + +-keepclasseswithmembers class **$$serializer { + *** serializer(...); +} + +-dontnote kotlinx.serialization.AnnotationsKt