Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message when io.realm.kotlin plugin is not applied to module containing module classes #676

Closed
cmelchior opened this issue Feb 11, 2022 · 1 comment
Assignees

Comments

@cmelchior
Copy link
Contributor

cmelchior commented Feb 11, 2022

If the user forgets to add the io.realm.plugin to the Gradle module containing the model classes, opening the Realm will crash with a rather unhelpful error message:

2022-02-11 20:39:01.377 8805-8854/com.mongodb.hellosyncrealm E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1
    Process: com.mongodb.hellosyncrealm, PID: 8805
    java.lang.IllegalStateException: Couldn't find companion object of class VisitInfo
        at io.realm.internal.platform.RealmObjectKt.realmObjectCompanion(RealmObject.kt:28)
        at io.realm.internal.ConfigurationImpl.<init>(ConfigurationImpl.kt:78)
        at io.realm.mongodb.SyncConfiguration$Builder.build(SyncConfiguration.kt:142)
        at com.mongodb.hellosyncrealm.ui.home.HomeViewModel$updateData$1.invokeSuspend(HomeViewModel.kt:46)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:39)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

We should improve the error message for this case. Maybe something like:

 java.lang.IllegalStateException: Couldn't find companion object of class VisitInfo. A common cause for this is when the `io.realm.plugin` is not applied to the Gradle module that contains the VisitInfo class.
@nhachicha
Copy link
Collaborator

fixed via #698

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants