Conversation
릴리즈 빌드에 minifyEnabled true, shrinkResources true 적용. 공식 문서 기반 ProGuard rules 작성 (Firebase Crashlytics, Kakao SDK, Gson). AAB 용량 54MB → 46.8MB (14% 감소).
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughEnables code minification and resource shrinking for release builds in Gradle and replaces ProGuard rules: adds Crashlytics-related keeps, retains Kakao SDK model fields, and removes a previous Gson TypeAdapter keep rule. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| buildTypes { | ||
| release { | ||
| minifyEnabled false | ||
| minifyEnabled true |
There was a problem hiding this comment.
공식 근거: Android 공식 문서 — 앱 축소, 난독화 및 최적화
R8은 기본적으로 코드 축소, 리소스 축소, 난독화, 최적화를 수행합니다.
minifyEnabled true로 R8을 활성화하고,shrinkResources true로 사용되지 않는 리소스를 제거합니다.
AGP 8.13.2 기준 R8은 compatibility mode(기본)로 동작하며, 각 라이브러리의 consumer rules를 자동으로 병합합니다.
| # public *; | ||
| #} | ||
| # --- Firebase Crashlytics --- | ||
| # 난독화된 스택 트레이스를 읽을 수 있도록 소스 파일명/라인 번호 유지 |
There was a problem hiding this comment.
공식 근거: 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으로 원본 파일명을 복원할 수 있게 합니다.
There was a problem hiding this comment.
정정: 두 가지 부정확한 부분이 있었습니다.
-
-keep public class * extends java.lang.Exception은 공식 문서에서 Optional로 표시되어 있습니다. 필수가 아니라 선택 사항입니다. 다만 커스텀 Exception 클래스명 보존을 위해 유지합니다. -
-renamesourcefileattribute SourceFile은 Firebase 공식 문서에 포함되지 않은 규칙입니다. ProGuard/R8 커뮤니티에서 널리 쓰이는 관행이며, Crashlytics mapping 파일이 원본 파일명을 복원할 수 있어 호환은 되지만 공식 근거로 제시한 것은 부적절했습니다. 제거합니다.
app/proguard-rules.pro
Outdated
| # 공식 문서: https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android | ||
| -keepattributes SourceFile,LineNumberTable | ||
| -keep public class * extends java.lang.Exception | ||
| -renamesourcefileattribute SourceFile |
There was a problem hiding this comment.
공식 근거: Kakao Developers — Getting Started (축소/난독화 설정)
To enable shrinking, obfuscation, and optimization when building the release version of your app, add the following codes in the ProGuard rules file to exclude the Kakao SDK from shrinking and obfuscation:
-keep class com.kakao.sdk.**.model.* { <fields>; }
Kakao SDK는 model 클래스에서 Gson 리플렉션을 사용하므로 필드를 유지해야 합니다. v2-user AAR에는 AppLifecycleObserver keep만 포함되어 있어, model 규칙은 수동 추가가 필요합니다.
app/proguard-rules.pro
Outdated
| -keep class com.kakao.sdk.**.model.* { <fields>; } | ||
| -keep class * extends com.google.gson.TypeAdapter No newline at end of file | ||
|
|
||
| # --- Gson --- |
There was a problem hiding this comment.
공식 근거:
Gson 2.11+ 부터 기본 consumer rules가 포함되어야 하지만, 현재 사용 중인 Gson 2.13.2 JAR에는
META-INF/proguard/디렉터리가 포함되어 있지 않아 수동 추가가 필요합니다.
TypeAdapter keep: Gson이 리플렉션으로 커스텀 TypeAdapter를 찾으므로 난독화 시 클래스명이 바뀌면 런타임 오류 발생.
@SerializedName keep: 이 프로젝트에서 Gson을 사용하는 DTO (RequestDeleteUploadCourse, RequestPatchPublicCourse, ResponseGetRefreshToken 등 9개 파일)의 필드명을 유지해야 JSON 직렬화가 정상 동작합니다.
There was a problem hiding this comment.
정정: Gson 2.13.2 JAR에 consumer rules가 없다는 주장은 오류였습니다.
확인 결과 META-INF/proguard/gson.pro (3,180 bytes)가 정상적으로 포함되어 있습니다. 이전 확인 시 sources JAR을 조회한 것으로 추정됩니다.
따라서 proguard-rules.pro의 Gson 수동 규칙(TypeAdapter keep, @SerializedName keep)은 중복이므로 제거합니다.
consumer rules 자동 적용 목록에 Gson도 추가해야 합니다.
| # 각 라이브러리의 공식 문서 또는 공식 저장소에 근거한 규칙만 포함합니다. | ||
| # consumer rules로 자동 적용되는 라이브러리는 별도 규칙을 추가하지 않습니다. | ||
| # (Retrofit, OkHttp, Kotlin Serialization, Glide, Naver Map SDK, DataBinding, Hilt) | ||
|
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/build.gradle`:
- Around line 66-67: Add a ProGuard/R8 keep rule to app/proguard-rules.pro to
prevent drawable fields referenced only via getIdentifier() from being removed;
the dynamic lookups occur in ContextExt (the functions that call getIdentifier)
and the BindingAdapter that resolves stamp drawables, so add a rule to keep the
R$drawable fields (or a narrower rule matching your stamp drawable name pattern)
so those resources aren’t stripped in release builds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 58337af5-8093-406e-bc21-40fd4a006731
📒 Files selected for processing (2)
app/build.gradleapp/proguard-rules.pro
- Gson 2.13.2 JAR에 consumer rules(gson.pro)가 포함되어 있으므로 수동 규칙 제거 - -renamesourcefileattribute는 Firebase 공식 문서 근거가 아니므로 제거
Summary
minifyEnabled true) 및 리소스 축소(shrinkResources true) 적용AAB 용량 비교
minifyEnabled falseminifyEnabled true+shrinkResources trueProGuard Rules 근거
각 규칙의 공식 근거는 PR 코멘트에 인라인으로 첨부합니다.
Test Plan
Summary by CodeRabbit