반응형

https://github.com/MaikuB/flutter_local_notifications/issues/2336

🔍 AGP 8에서 zonedSchedule 알림이 작동하지 않는 문제 요약 (#2336)

 

zonedSchedule notifications not working in AGP8 · Issue #2336 · MaikuB/flutter_local_notifications

Describe the bug After upgrading AGP to version 8.4, zonedSchedule notifications causes app to crash To Reproduce Use this minimally altered sample project: NotificationsSample Run Pixel 7 API 33 e...

github.com

 

🛠️ 문제 요약

 

Flutter 프로젝트에서 Android Gradle Plugin (AGP) 8.5로 업그레이드한 후 zonedSchedule 알림을 사용하면 앱이 충돌하는 버그가 발생함.

📌 오류 메시지:

java.lang.RuntimeException: Missing type parameter.

📌 발생 조건:

AGP 8.5사용

zonedSchedule 실행 시 앱 크래시

 

🕵️ 문제 원인 분석

1. R8(Code Shrinker) 관련 문제

R8이 특정 클래스를 최적화하면서 필요한 코드가 제거됨

android.enableR8.fullMode = false 설정 시 문제 해결됨 → 그러나 근본적인 해결책은 아님

2. GSON 관련 문제 (com.google.gson.reflect.TypeToken 누락)

AGP 8.5에서 특정 버전의 GSON이 제대로 작동하지 않음

app/build.gradle에 아래 추가 시 문제 해결됨

implementation 'com.google.code.gson:gson:2.11.0'

 

3. ProGuard 설정 부족

proguard-rules.pro에 GSON 관련 규칙이 없으면 충돌 발생

아래 규칙 추가 시 해결 가능

-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

 

 

 

1️⃣ proguard-rules.pro 수정

-keep class org.xmlpull.** { *; }
-keep class com.google.gson.** { *; }
-keep class com.dexterous.flutterlocalnotifications.** { *; }
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

2️⃣ GSON 버전 업데이트 (build.gradle 수정)

implementation 'com.google.code.gson:gson:2.11.0'

 

4️⃣ Gradle 설정 확인 (gradle.properties 수정)

android.enableR8.fullMode = false

📌 최종 결론

AGP 8.5에서 zonedSchedule 사용 시 R8과 GSON 관련 문제가 있음

proguard-rules.pro, build.gradle 설정 수정 후 해결됨

Flutter 최신 버전에서는 기본적으로 GSON 2.11.0을 사용하도록 변경됨

 

🔍 추가 참고 사항

최신 Flutter 3.27프로젝트에서는 기본적으로 Java 17호환 설정 유지됨

**Android Studio Ladybug(2024년 출시)**에서는 JDK 17 → 21로 변경됨

향후 Flutter 및 AGP 업데이트에서 추가적인 수정이 필요할 수 있음

 

🔹 요약: 위 해결 방법을 적용하면 flutter_local_notificationszonedSchedule 충돌 문제를 해결할 수 있음 🚀

반응형

+ Recent posts