Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공식 근거: Android 공식 문서 — 앱 축소, 난독화 및 최적화

R8은 기본적으로 코드 축소, 리소스 축소, 난독화, 최적화를 수행합니다.
minifyEnabled true로 R8을 활성화하고, shrinkResources true로 사용되지 않는 리소스를 제거합니다.

AGP 8.13.2 기준 R8은 compatibility mode(기본)로 동작하며, 각 라이브러리의 consumer rules를 자동으로 병합합니다.

shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
Expand Down
35 changes: 13 additions & 22 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# ===========================
# Runnect ProGuard/R8 Rules
# ===========================
# 각 라이브러리의 공식 문서 또는 공식 저장소에 근거한 규칙만 포함합니다.
# consumer rules로 자동 적용되는 라이브러리는 별도 규칙을 추가하지 않습니다.
# (Retrofit, OkHttp, Kotlin Serialization, Glide, Naver Map SDK, DataBinding, Hilt, Gson)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consumer rules 자동 적용 확인 결과 (수동 규칙 추가 불필요):

라이브러리 consumer rules 위치 확인 방법
Retrofit 2.9.0 META-INF/proguard/retrofit2.pro (JAR 내장) 공식 docs — "R8/ProGuard users: rules are included automatically"
OkHttp 4.12.0 META-INF/proguard/okhttp3.pro (JAR 내장) 공식 GitHub
Kotlin Serialization 1.10.0 META-INF/com.android.tools/r8/ (JAR 내장, R8 전용 규칙 포함) PR #2092
Glide 5.0.5 proguard.txt (AAR 내장) 공식 docs
Naver Map SDK 3.23.2 proguard.txt (AAR 내장 — NativeApi, geometry, JNI 등) AAR 직접 확인
DataBinding 8.13.2 proguard.txt (AAR 내장) AAR 직접 확인
Hilt 2.56.2 KSP가 META-INF/proguard/ 규칙을 자동 생성 공식 docs

# 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 *;
#}
# --- Firebase Crashlytics ---
# 난독화된 스택 트레이스를 읽을 수 있도록 소스 파일명/라인 번호 유지
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공식 근거: Firebase Crashlytics — Get readable crash reports

To get readable (deobfuscated) crash reports, add the following lines to your ProGuard configuration:

-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

-renamesourcefileattribute SourceFile은 소스 파일명을 "SourceFile"로 통일하여 APK 크기를 추가 절감하면서도 Crashlytics mapping으로 원본 파일명을 복원할 수 있게 합니다.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정정: 두 가지 부정확한 부분이 있었습니다.

  1. -keep public class * extends java.lang.Exception은 공식 문서에서 Optional로 표시되어 있습니다. 필수가 아니라 선택 사항입니다. 다만 커스텀 Exception 클래스명 보존을 위해 유지합니다.

  2. -renamesourcefileattribute SourceFileFirebase 공식 문서에 포함되지 않은 규칙입니다. ProGuard/R8 커뮤니티에서 널리 쓰이는 관행이며, Crashlytics mapping 파일이 원본 파일명을 복원할 수 있어 호환은 되지만 공식 근거로 제시한 것은 부적절했습니다. 제거합니다.

# 공식 문서: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# https://developers.kakao.com/docs/latest/en/getting-started/sdk-android#configure-for-shrinking-and-obfuscation-(optional)
# --- Kakao SDK ---
# 공식 문서: https://developers.kakao.com/docs/latest/en/android/getting-started#configure-for-shrinking-and-obfuscation-(optional)
-keep class com.kakao.sdk.**.model.* { <fields>; }
-keep class * extends com.google.gson.TypeAdapter
Loading