realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
964 stars 61 forks source link

Mixing Robolectric tests with normal tests throws Error on Android with Kotlin multiplatform #1843

Open Burtan opened 1 month ago

Burtan commented 1 month ago

How frequently does the bug occur?

Always

Description

Hey,

if you use Kotlin Multiplatform with an Android module and Realm you most likely also use Robolectric. If you run some realm tests with Robolectric and some without, Realm throws the following error. It works with all tests running on Robolectric.

Stacktrace & log output

java.lang.ExceptionInInitializerError
    at io.realm.kotlin.internal.interop.RealmInteropKt.INVALID_CLASS_KEY_delegate$lambda$0(RealmInterop.kt:43)

Can you reproduce the bug?

Always

Reproduction Steps

Here is an example project.

Version

2.3.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Linux Debian testing

Build environment

Android Studio version: 2024.1.2 Patch 2 Android Build Tools version: 8.6.1 Gradle version: 8.10.2

sync-by-unito[bot] commented 1 month ago

➤ PM Bot commented:

Jira ticket: RKOTLIN-1131