728x90
- Android Studio (1.4 이상 plugin 설치) 에서 Kotlin Object Class 에 대해서 field 에 Context 를 선언할 경우 Warning 에러가 발생한다.
- Error Message
Do not place Android context classes in static fields (static reference to AppContext which has field activityContext pointing to Context); this is a memory leak
- 해결 방법
1. @SuppressLint("StaticFieldLeak") Annotation 추가한다.
2. context 를 Object class 에 넘겨주는 대신 Application Context 를 가져와서 참조하도록 처리 한다.
728x90
'Android > Kotlin' 카테고리의 다른 글
[BOJ][KOTLIN] 2447 별 찍기 - 10 (0) | 2021.11.20 |
---|---|
Subroutine (0) | 2020.06.15 |
MutableList (0) | 2020.06.15 |