RealmModule gets replaced in the library

61 views Asked by At

MongoDB Realm: io.realm:realm-gradle-plugin:10.16.1

I have a library which defines

@RealmModule(library=true, allClasses=true)
class LibraryModule() {}

and has a function LibraryDatabaseConfiguration() which

return new RealmConfiguration.Builder()...modules(new LibraryModule()).build()

In the application code

var database = Realm.getInstance(LibraryDatabaseConfiguration())

gives me access to the database with schema defined in the library - as expected.

In application after adding

@RealmModule(classes={storage1.class, storage2.class})
class AppModule() {}

and function AppDatabaseConfiguration() which

return new RealmConfiguration.Builder()...modules(new AppModule()).build()

function LibraryDatabaseConfiguration() returns configuration with schema defined in the app instead of library.

I verify this by iterating thru

database.getSchema().getAll()

The question is - how can I keep configurations in library using correct @RealmModule ?

Submitted bug report: https://github.com/realm/realm-java/issues/7855

1

There are 1 answers

1
Andriy On

The bug has been confirmed, workaround and work progress can be found [on github].1

Workaround: each @RealmModule class must have unique name.