Room 라이브러리 사용할 때 생기는 오류다.
코틀린으로 변경하고 난 후 Room database 객체를 싱글톤으로 가져오도록 로직을 추가했는데 그것 때문인지 아니면 지금 코틀린 변환하는 작업 때문에 난 에러인지 몰라서 한참 찾았다.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m3s.skylark/com.m3s.skylark.LoginActivity}: java.lang.RuntimeException: cannot find implementation for com.m3s.skylark.MyAppDatabase. MyAppDatabase_Impl does not exist
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2981)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3042)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1639)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6780)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: java.lang.RuntimeException: cannot find implementation for com.m3s.skylark.MyAppDatabase. MyAppDatabase_Impl does not exist
at androidx.room.Room.getGeneratedImplementation(Room.java:94)
at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:952)
at com.m3s.skylark.MyAppDatabase$Companion$1.invoke(MyAppDatabase.kt:43)
at com.m3s.skylark.MyAppDatabase$Companion$1.invoke(MyAppDatabase.kt:34)
at com.m3s.skylark.SingletonHolder.getInstance(SingletonHolder.kt:20)
at com.m3s.skylark.LoginActivity.onCreate(LoginActivity.kt:65)
at android.app.Activity.performCreate(Activity.java:6948)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3042)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1639)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6780)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
impl 파일 원래 room이 알아서 만들어주는 거자나...
build.gradle(APP) 안에다가 plug-in 과 dependency 추가해주자.
apply plugin: 'kotlin-kapt'
android {
...
dependency{
...
kapt 'android.arch.persistence.room:compiler:1.1.1'
...
}
}