Skip to content

fix: R8 난독화 시 Retrofit API 호출 실패 해결#382

Closed
unam98 wants to merge 1 commit intodevelopfrom
hotfix/proguard-retrofit-result
Closed

fix: R8 난독화 시 Retrofit API 호출 실패 해결#382
unam98 wants to merge 1 commit intodevelopfrom
hotfix/proguard-retrofit-result

Conversation

@unam98
Copy link
Copy Markdown
Collaborator

@unam98 unam98 commented Apr 4, 2026

작업 배경

R8 난독화(#379) 적용 후 릴리즈 빌드에서 모든 API 호출이 실패하는 버그 발생. 디버그 빌드에서는 정상 동작.

원인 분석

1. kotlin.Result 제네릭 타입 소실

  • kotlin.Result는 inline(value) class → R8이 제네릭 Signature 속성을 최적화
  • Retrofit이 Call<Result<T>>의 타입 파라미터를 리플렉션으로 읽지 못함
  • ResultCallAdapterFactory에서 IllegalArgumentException: Unable to create call adapter 발생
  • 이 에러로 인해 모든 API 요청이 아예 나가지 않았음

2. BaseResponse DTO 필드명 난독화

  • ResponseInterceptor에서 Gson으로 BaseResponse를 역직렬화
  • BaseResponse@SerialName(Kotlin Serialization)만 선언, @SerializedName(Gson) 없음
  • R8이 필드명을 난독화하면 Gson 매핑 실패

변경 사항 (app/proguard-rules.pro)

# kotlin.Result inline class 보존
-keep class kotlin.Result { *; }
-keepattributes Signature

# BaseResponse/ErrorResponse 필드명 보존 (Gson 역직렬화용)
-keepclassmembers class com.runnect.runnect.data.dto.response.base.** { <fields>; }

영향 범위

  • 릴리즈 빌드의 모든 API 호출에 영향
  • ProGuard rules 추가만으로 코드 변경 없음

Test Plan

  • 릴리즈 APK 빌드 → 실 디바이스 설치 → 방문자 모드 API 정상 응답 확인
  • 카카오/구글 로그인 정상 동작 확인
  • 에러 응답 파싱 정상 확인

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated build configuration to ensure proper app functionality and reliability when compiled for release.

1. kotlin.Result 제네릭 타입 정보 보존 (-keep class kotlin.Result)
   - R8이 inline class인 kotlin.Result의 Signature를 최적화하면서
     Retrofit의 ResultCallAdapterFactory가 Call<Result<T>> 타입을 인식 못함
   - square/retrofit#3880

2. BaseResponse/ErrorResponse DTO 필드명 보존 (-keepclassmembers)
   - ResponseInterceptor에서 Gson으로 역직렬화 시 필드명 매핑 실패 방지
   - 범위를 data.dto.response.base 패키지로 한정
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5d42e00-985d-4a75-a743-3f2cc6e2b1a3

📥 Commits

Reviewing files that changed from the base of the PR and between 7417e63 and ff07d95.

📒 Files selected for processing (1)
  • app/proguard-rules.pro

📝 Walkthrough

Walkthrough

ProGuard/R8 keep rules were added to preserve runtime type information for Retrofit's kotlin.Result handling and to prevent obfuscation of field names in DTO response classes, ensuring Gson can deserialize JSON responses correctly.

Changes

Cohort / File(s) Summary
ProGuard Configuration
app/proguard-rules.pro
Added keep rules to preserve kotlin.Result class members and signature attributes for Retrofit compatibility. Added keepclassmembers rules for DTO response classes in com.runnect.runnect.data.dto.response.base.** to prevent field name obfuscation during Gson deserialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through reflection's maze,
Where Retrofit dances and Gson plays,
Keep these rules, and all is well—
No fields obfuscated, secrets to tell! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing Retrofit API call failures when R8 obfuscation is applied, which is exactly what the ProGuard rules modifications address.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/proguard-retrofit-result

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@unam98
Copy link
Copy Markdown
Collaborator Author

unam98 commented Apr 4, 2026

kotlin.Result 규칙을 #381에 합쳐서 하나의 PR로 진행

@unam98 unam98 closed this Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant