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

Model cannot be cast to ModelRealmProxyInterface while using realm jars built from source in Android Project #7875

Open
73sravanthi opened this issue Mar 7, 2024 · 6 comments

Comments

@73sravanthi
Copy link

73sravanthi commented Mar 7, 2024

How frequently does the bug occur?

Always

Description

I am using Realm jars which are built from source code. I have added realm-library aar file, realm-annotations-10.18.0.jar, realm-transformer-10.18.0.jar, realm-gradle-plugin into libs folder of Android project and tried to build. Able to launch the application however getting

UserModel cannot be cast to io.realm.com_example_mobile_test_auth_model_UserModelRealmProxyInterface
whenever any db operation is performed

Stacktrace & log output

2024-03-07 15:45:21.304  5922-5922  ExampleException         com.example        D  null : null
2024-03-07 15:45:21.305  5922-5922  ExampleException          com.example         D
 UserModel cannot be cast to io.realm.com_example_mobile_test_auth_model_UserModelRealmProxyInterface

Can you reproduce the bug?

Always

Reproduction Steps

Build the realm code base from source

Version

10.18.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Mac OS 14.3

Build environment

Android Studio version: Android Studio Hedgehog | 2023.1.1 Patch 2
Android Build Tools version: 33.0.1
Gradle version: 8

Copy link

sync-by-unito bot commented Mar 7, 2024

➤ PM Bot commented:

Jira ticket: RJAVA-1251

@73sravanthi
Copy link
Author

Any help on this. Stuck with the above error and unable to proceed

@rorbech
Copy link
Contributor

rorbech commented Mar 13, 2024

Looks like you are not transforming the realm model classes. If you don't apply our plugin you will have to register the transformer yourself.

@73sravanthi
Copy link
Author

73sravanthi commented Mar 18, 2024

Adding the realm-transformer jar file to libs doesn't help here?
Is there any way to apply the plugin using jar file.
Earlier I used android.registerTransform(new RealmTransformer(rootProject)) to register but in Gradle 8 android.registerTransform is deprecated.

@73sravanthi
Copy link
Author

Any help on this

@73sravanthi
Copy link
Author

I have tried using

import io.realm.transformer.RealmTransformerKt
RealmTransformerKt.registerRealmTransformerTask(rootProject)

to register the RealmTransformer in the build.gradle file, however getting below error while trying to build it

Caused by: org.gradle.api.UnknownDomainObjectException: Extension of type 'AndroidComponentsExtension' does not exist. Currently registered extension types: [ExtraPropertiesExtension, KtlintExtension]
at org.gradle.internal.extensibility.ExtensionsStorage.getHolderByType(ExtensionsStorage.java:88)
at org.gradle.internal.extensibility.ExtensionsStorage.getByType(ExtensionsStorage.java:74)
at org.gradle.internal.extensibility.DefaultConvention.getByType(DefaultConvention.java:160)
at org.gradle.internal.extensibility.DefaultConvention.getByType(DefaultConvention.java:155)
at io.realm.transformer.RealmTransformerKt.registerRealmTransformerTask(RealmTransformer.kt:88)
at io.realm.transformer.RealmTransformerKt$registerRealmTransformerTask.call(Unknown Source)

Let me know if I missed anything here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants