Android - Realm does not work in a project with more than one module
See original GitHub issueGoal
- I have 2 modules where realm is located. One handles the database generic and another the database of the actually application. However When I try to add a RealmObject to the @RealmModule class it keeps telling me the RealmObject is not an object. However, if I change the location of the class to the application database module it actually works…
Exception trying to compile is the following:
e: error: RealmOne could not be added to the module. Only classes extending RealmObject or implementing RealmModel, which are part of this project, can be added.
Steps & Code to Reproduce
Application Module
- UserRealmModule
@RealmModule(classes = [RealmOne::class, RealTwo::class], library = true)
class UserRealmModule
Generic Database Module
- RealmOne
open class RealmOne(
@Required
@PrimaryKey
@RealmField(REALM_ONE_ID)
var id: String = ""
) : RealmObject()
- RealmTwo
open class RealmTwo(
@Required
@PrimaryKey
@RealmField(REALM_TWO_ID)
var id: String = ""
) : RealmObject()
Version of Realm and tooling
Realm version(s): {{io.realm:realm-gradle-plugin:5.8.0 }}
Android Studio version: 3.5.2
Android Build Tools version: 28.0.3
Gradle version: com.android.tools.build:gradle:3.5.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Realm Android - Multiple RealmModule for mutiple libraries
As it looks like, the problem was that the two modules were creating a single instance of the Realm object, which then lead...
Read more >Realm: Create reactive mobile apps in a fraction ... - MongoDB
Missing Realm Constructor · Close all simulators/device builds · Stop the package manager running in terminal (or better yet, just restart terminal) ·...
Read more >Create reactive mobile apps in a fraction of the time - Realm
We do not support Java outside of Android at the moment. ... Your Realm version needs to be higher than 0.81.1. ... RealmModule...
Read more >Realm on Android Library (module)
How to configure your realm instance on multi-module projects. ... RealmObject is not part of the schema I have run into this error...
Read more >Known issues with Android Studio and Android Gradle Plugin
To fix this issue, upgrade your Android 11 emulator to version 9 or higher by navigating to Tools > SDK Manager. In the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@luispereira Why not just expose a module from the generic database module and combine them when opening the Realm?
Yes @Zhuinden, but wouldn’t that impact only runtime? I’m having an issue in compile time