Crash for desktop but works fine for Android and emulator

I have some code that works great for Android and the emulator, but when I try to run it from the desktop it crashes with a null pointer exception. Can anyone see what it is I am doing wrong?

object RealmRepo {
    lateinit var realm: Realm
    var userEmail = ""
    var practiceName = ""
    private var initialized = false
    private lateinit var registerPractice : Practice
    private lateinit var userAccount : UserAccount

    private val appServiceInstance by lazy {
        // If logs are on app level then it set for everything ..
        val configuration =
            AppConfiguration.Builder("application-0-rpbsh")
                .log(LogLevel.ALL).build()

        App.create(configuration)        //***        Null pointer happens here     ***

    }

    init {
        if (!initialized) {
            setupRealmSync()
            initialized = true
        } else {
            throw IllegalStateException("Singleton instance already created.")
        }
    }
    private fun setupRealmSync() {
        val user = runBlocking { appServiceInstance.currentUser!! }
        val config = SyncConfiguration
            .Builder(
                user,
                setOf(UserAccount::class,Pellet::class, PelletInsertionVisit::class, PelletLot::class, Patient::class,
                    Practice::class )
            )
            .initialSubscriptions(rerunOnOpen = true) { realms ->
                add(
                    realms.query<PelletInsertionVisit>(),
                    name = "patient info",
                    updateExisting = true
                )
                add(realms.query<PelletLot>(), name = "Pellet info", updateExisting = true)
                add(realms.query<Patient>(), name = "Patient info", updateExisting = true)
                add(realms.query<Practice>(), name = "Practice info", updateExisting = true)
                add(realms.query<UserAccount>(), name = "UserAccount info", updateExisting = true)

            }
            .build()
        realm = Realm.open(config)
    }

Hi @Darrin_Smith1,

To better understand the issue, please share the following:

  1. Error message with stacktrace.
  2. Code where the RealmRepo object and function are used.

I would also like to clarify what you mean by “run it from the desktop”. And how are you verifying that it is working properly on Android/Emulator?

Are you also referring to this doc for setting up Realm Device Sync?