1. ERROR: R8: Missing class org.tensorflow.lite.gpu.GpuDelegateFactory$Options
YOLO 모델중 하나인 yolov8n 을 사용하는 프로젝트에서 배포파일을 생성하던 도중 발생한 문제이다.
아래의 명령어를 이용해, appbundle 파일을 만드는 과정에서 발생했다.
// Terminal
flutter build appbundle --release
이 오류는
org.tensorflow.lite.gpu.GpuDelegateFactory$Options 클래스를 참조하는 라이브러리가 빌드 중 제거되었다는 오류인것 같다.
해결하기 위해서는 프로젝트에 Proguard 규칙을 추가해주어야 한다.
// proguard-rules.pro
-keep class org.tensorflow.** { *; }
-dontwarn org.tensorflow.**
ERROR: R8: Missing class org.tensorflow.lite.gpu.GpuDelegateFactory$Options는 빌드 중에 R8(또는 Proguard)이 TensorFlow Lite 라이브러리에서 필요로 하는 클래스를 "사용되지 않는 코드"로 오인하여 제거했기 때문에 발생하게 된다고 한다. 이 클래스는 실행 시점에 동적으로 참조되므로, R8은 이를 필요하지 않은 코드로 간주할 가능성이 높기 때문에, Proguard 규칙을 통해 해당 클래스를 제거하지 않도록 방지해 주어야 한다.
이 파일을 만들어서 Android/app 파일에 넣어주자.
해결!
## 번외
위의 방법을 사용해도 해결되지 않을 경우 아래 포스팅을 참고해보자
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in 안드로이드 APP 개발 하다가, debug build로 개발하면 문제가 없는데, relase 개발하면 해당 에러가 발
coinpipe.tistory.com
'TIL' 카테고리의 다른 글
TIL - MUOZ (2) (오디오 플레이어 UI) (0) | 2025.02.08 |
---|---|
TIL - MUOZ (1) (오디오 플레이어 - Just Audio) (0) | 2025.02.07 |
TIL - ndk-bundle did not have a source.properties file (Flutter) (0) | 2025.01.14 |
TIL - A1one(1) < Firebase Cloud Function > (0) | 2025.01.08 |
TIL - 영화 정보앱 (4) < Go_router Transition 효과의 문제점! > (0) | 2024.12.30 |