Unresolved reference: RealmObject

I am trying to set up an Android app using Realm Sync. I already have all my schema etc. set up, so I wanted to just import my existing objects into a new Android app in Android Studio.

I have followed these instructions and (for the first time ever!) they seem to have actually worked! (Yay! My experience with Android Studio and Gradle files in the past has been that very little works the way it’s supposed to.)

However, when I paste my objects from the online App Services portal into a new .kt file, I get errors, Unresolved reference: RealmObject etc. It can’t seem to find io.realm or org.bson and I don’t know why.

What am I doing wrong?

Ok, so looking at this docs page it seems the online tool generates code for the older Android/Java SDK. Do I have to convert this manually? (I’m having a go now.) Is there a way to get the new Kotlin SDK syntax out instead?

… and how do I translate a RealmDictionary? I can’t find any mention of it in the Kotlin SDK docs.

So at this point, it looks like:

  1. My online App Services page will only generate object model code for the old Java-based SDK. (Is this expected?)
  2. The new Kotlin SDK does not (yet?) support dictionaries, which I am already using.

So much for my experiment with the new Kotlin SDK. I’m just going to try using the old one.