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.

Hey everyone!

First off, big cheers for sharing your experience, polymath74! Navigating the intricate world of Android development can indeed be a rollercoaster of emotions, and I’m thrilled to see you making progress despite the challenges.

Now, diving into your current hiccup, the Unresolved reference: RealmObject issue seems to be a classic twist in this journey. It looks like the online tool is spitting out code for the older Java-based SDK, which is probably why Kotlin’s giving you the cold shoulder. Converting it manually could be an option, but let’s explore other avenues.

Since the new Kotlin SDK is still catching up, I’d suggest going the ‘old school’ route for now. You’ve got the spirit for experimentation, so it’s not a retreat but rather a well-thought pivot.

Believe me, sometimes going the “old school” route is a great decision. I have many years of experience in mobile development at one of the best German android app entwicklung agentur I have resorted to old technologies many times. And it has often worked out well for me.

I’m interested to observe your reflections. You seem to me a very talented developer and I believe you have a great future. Do you have a social media presence, or maybe a blog? I would love to follow what you are doing.

Thanks Alex. Yes, I have now built my Android app using the old Java SDK.

No social media sorry. I’m actually relatively new to mobile apps. I used to be a back end developer. (I’m talking long ago - more than 2 decades ago!)