Room cannot find implementation

前端 未结 11 1822
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 07:17

I have a problem with testing a Room database: when I run the test, I get this exception:

java.lang.RuntimeException: cannot find implementation for databa         


        
11条回答
  •  -上瘾入骨i
    2020-12-09 07:59

    I see some people around here (Vishu Bhardwaj and others on similar StackOverflow questions) complains the accepted answer does not work for them. I think it deserve mentioning I had a similar problem in a MULTI modules project that needed a trick around the accepted answer.

    In my multi modules project the room database dependencies where included mostly in one basic module and exported using proper api notation but room code was split along 2 different modules. Project compiled with no warning but java.lang.RuntimeException: cannot find implementation for database... was raised on run-time.

    This was fixed by adding

    annotationProcessor "android.arch.persistence.room:compiler:$room_version"
    

    in ALL modules that included Room related code.

提交回复
热议问题