[안드로이드 공부] 215

listOf()와 emptyList() 차이

listOf()와 emptyList() 모두 코틀린에서 빈 리스트를 생성하는 함수. listOf()는 가변 인자를 받아서 리스트를 생성하는 함수다. 인자 없이 호출하면 빈 리스트를 반환한다.  emptyList()는 항상 빈 리스트를 생성하는 함수로 listOf()와 emptyList()는 인자 없이 호출할 경우 동일한 결과, 즉 빈 리스트를 반환함. 그러나 이 두 함수 사이에는 성능 차이가 있다. emptyList()는 항상 같은 인스턴스를 반환하기 때문에 새로운 객체를 생성하지 않음. 반면에 listOf()는 호출할 때마다 새로운 리스트를 생성함.  따라서 빈 리스트를 생성할 때는 emptyList()를 사용하는 것이 더 효율적.

Missing type, Progard, Generic 문제

java.lang.RuntimeException: Missing type parameter. at cohttp://m.google.gson.reflect.TypeToken.getSuperclassTypeParameter(Unknown Source:26) at cohttp://m.google.gson.reflect.TypeToken.(SourceFile:1) at U2.e$a.(SourceFile:1) at U2.e.a(SourceFile:8) 1. 위와 같은 문제 발생시 위치를 알기 어렵다. --> Release, Debug 모두 확인 시 Release 에서만 발생 확인 2. Release 에서만 발생 --> 의심; minify, progard --> 소스를 제대로 읽지 못해 발생 할 수 있으므로 2. ..

Caused by: java.lang.IllegalArgumentException: MaterialThemeUsingMdcTheme requires the host context's theme to extend Theme.MaterialComponents

Caused by: java.lang.IllegalArgumentException: MaterialThemeUsingMdcTheme requires the host context's theme to extend Theme.MaterialComponents at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme(MdcTheme.kt:134) at com.google.android.material.composethemeadapter.MdcTheme.createMdcTheme$default(MdcTheme.kt:125) at com.google.android.material.composethemeadapter.MdcTheme.Mdc..

반응형