-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
Hello,
I have a similar problem with the one indicated in this StackOverflow post when minifyEnabled is set to true.
Basically, I can run my app without any problem with Kotlin 1.7.21 and Realm-Kotlin 1.5.2 (and AGP 7.3.1).
The problem is when I upgrade to Kotlin version 1.8.0, I get the same error as in the above linked post:
> Caused by: java.lang.IllegalArgumentException: Only subclasses of RealmObject and EmbeddedRealmObject are allowed in the schema. Found: my.package.MyRealmDataModel
The problem occurs when building a RealmConfiguration because it calls the io.realm.kotlin.Configuration.SharedBuilder constructor, in which the exception is thrown. The reason the error happens is because clazz.realmObjectCompanionOrNull() returns null, which calls clazz.companionObjectInstance which loops through the class’ nestClasses and finds out the first for which their description.isCompanionObject property returns true.
By using the debugger, I managed to reached that code and discovered that the descriptor was a LazyJavaClassDescriptor instance. But, in this ClassDescriptor implementation, the isCompanionObject is always false.
I suspect this is due to code generation. Looking at the generated code in my build folder, my realm model is fully converted in java as well as the companion object, but I could be wrong.
I also tried all the rules mentioned in the linked StackOverflow post, to no avail.