So i am now trying to experiemnt with Room in mult...
# multiplatform
m
So i am now trying to experiemnt with Room in multiplatform, but having an issue. For the ios/native component when i try to call the the "instantiateImpl()" function on the AppDatabase kclass, it is coming up as unresolved. When i look in the build generated classes by ksp I can see the extension function. Why can't I call it in my code? For reference this is the code snippet I am speaking about:
Copy code
fun getDatabaseBuilder(): RoomDatabase.Builder<AppDatabase> {
    val dbFilePath = NSHomeDirectory() + "/my_room.db"
    return Room.databaseBuilder<AppDatabase>(
        name = dbFilePath,
        factory =  { AppDatabase::class.instantiateImpl() }
    )
}
j
I ran in to same problem and then noticed this in https://developer.android.com/kotlin/multiplatform/room
Having said that, it does still show up as unresolved in IDE (Android Studio stable at least) but does build with that setting
๐Ÿ™Œ 1
m
Oh thanks for that confirmation. I did see that fix, but also saw that it was still showing up as unresolved. Glad to know that it isn't just me experiencing that issue.
โž• 1
r
I'm unable to add it into gradle, how did you guys manage. I get
not found
. I created a new module, google maven is added to the project.
j
This is the project I'm using it in if you want to compare anything https://github.com/joreilly/FantasyPremierLeague
@Martin Gaynor did it work for you after that?
p
I came to this thread through @John O'Reilly project. ๐Ÿ™‚ Now I'm following this thread. ๐Ÿ™ƒ
j
Are folks here still having issues building? If so, does https://github.com/joreilly/FantasyPremierLeague build for you or. not (as opposed to "just" the error shown in the IDE)?
b
j
So, the import was main issue?
I copied over I think from official sample which is probably why I had it
b
Yes, even as mentioned in the issue tracker, I just used ksp(libs.room...) and commented out the add("ksp....) codes and still worked fine. It's just the import section was the issue. Thanks for your help too, just wanted to update here once that it's resolved.
I see. Thanks for your awesome repository though, it helped me a lot, and awesome work! ๐Ÿ˜
๐Ÿ‘ 1
m
@John O'Reilly sorry i took so long to get back to you. Yea it was working after that, but was still showing as an error in the IDE. Since then I have gone back to using sqldelight, as I wait for room to mature for multiplatform.
v
I also faced this issue. Importing the
instantiateImpl
class worked.
๐Ÿ™Œ 1