Android 52

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..

Android Studio build error - compileDebugJavaWithJavac task (current target it 1.8) and kaptGenerateStubsDebugKotlin task (current target is 17)

Before compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" freeCompilerArgs = listOf("-Xjvm-default=enable") } After >>> JavaVersion.VERSION_1_8.toString() compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = JavaVersio..

Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option

Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option viewModel 에 param을 추가하였더니 viewModel Factory가 필요하고, 추가 하니 위와 같은 에러가 나왔다~ 버전 충돌 문제인데~ build.gradle.app 에 kotlinOptions { jvmTarget = '1.8' freeCompilerArgs += [ '-Xjvm-default=enable' ] } 또는 tasks.withType(KotlinCompile).configureEach { kotlinOptions { freeCompilerArgs += [ "-Xjvm-default=all", ] } }..

Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements

switch 문에서 case R.id.xxxx 를 더 이상 제공 하지 않는다고 한다. 간단하게 if else 문으로 대체 하면 되는데 case 문이 많을 경우 난감하고 귀찮다. 이럴 때는 간단히 Refactoring 을 하면 된다. switch 에 커서를 올리고 Option(Windows Alt) + enter 를 치고 Replace switch with if 를 선택하면 한 방에 해결 된다.

LiveData 와 MutableLiveData

MutableLiveData는 Abstract Class 인 LiveData를 구현한 Public Class 위 말을 풀어 보면, 1. LiveData는 추상 클래스이므로 직접 생성할 수 없다. public abstract class LiveData { protected void postValue(T value) {} @MainThread protected void setValue(T value) {} //데이터 수정은 pretected 메서드를 구현해서 사용해야 한다. } val name : LiveData = LiveData() 위와 같이 직접 생성할 경우 아래와 같이 에러가 발생한다. cannot create an instance of an abstract class 반면에 MutableLiveDa..