android

[안드로이드/android] Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option 에러

hrniin 2023. 9. 20. 19:47
728x90

 

 

코틀린으로 안드로이드 프로젝트를 구현하던 도중 아래와 같은 오류가 발생했다.

나같은 경우에는 ViewModel.Factory 인터페이스를 구현한 부분에서 생긴 오류였다.

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

 

 

 

android {
	kotlinOptions {
         freeCompilerArgs = ['-Xjvm-default=compatibility']
    }
}

모듈 build.gradle의 android-kotlinOptions 안에 freeCompilerArgs 한줄을 넣어주면 해결된다!

서치해봐도 잘 나오질 않아서 멘탈 터질뻔 했다..

 

 

 

참고 https://stackoverflow.com/questions/53964192/jvmdefault-and-how-add-compiler-option 

 

 

 

 

728x90