-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Better error reporting for custom setters/getters #952
Comments
Does this also happen if you try to compile from the command line with: |
@cmelchior yes |
That is really odd. I could imagine there could be problems with if the dexer puts the RealmJsonImpl in the secondary dex file (see under multidex limitations here: https://developer.android.com/tools/building/multidex.html) But the annotation processor runs as part of the Java compiler so if it doesn't find all your model classes, something else is wrong.
|
Yes, all Realm related code is in app project. I cannot share this exact project but I started working on reproducible example. Will post it here when it's done or if it becomes clear that something else is wrong. |
Thank you, that will be very helpfull. |
In case it helps, my app uses multidex but does not use RealmJson and is building successfully under 0.80.0. |
I figured out what the problem was. Multidex is not related to it. Several of my realm classes implement interface like that:
Implementations have nothing to do with internal fields that are actually stored with that class data in realm or any getters and setters. Previous versions of Realm had less stricter rules for defining objects than 0.80 has. Getters not associated with to any field were allowed with warning message during build process ("Note Getter getX is not associated to any field"). In 0.80 as I see from I guess it would be better to fire error to Messager here and here. It will give clear understanding why annotation processing aborts - something wrong with declared realm objects. Also it should be covered in documentation and changelogs that custom getters and setters with no associated fields are not allowed since 0.80 and will cause a build error. I can make a PR if my suggestion fits right. |
Yes, we did restructure some things in the annotation processor because the code was getting unmanageable. That these setters/getters was allowed before was mostly an oversigt on our part and shouldn't have been possible until we could add better support overall for them. But a PR with better error reporting would be most welcome. |
Great. I'll send PR. |
Fix has been merged to master. Thanks for the PR. |
I am able to reproduce the bug. |
Oh. This is a terrible deal-breaker for me.
Is there anything that I can do in order to force Realm v.0.80.0 to accept my models? |
Hi @marcel-eggum |
Well, an example of a given model kan be seen here:
I find it strangly odd that this solution is no longer working as I retrieve the exact same Exceptions as @kboyarshinov notes in his original post. The use-case for such a solution is strongly cupeled to our generic-save function, where we create-or-update our entities when we synchronize with the backend - or delete unwanted entities if they are no longer present in the response that we retrieve:
The primary use of such an interface - is to ensure for the save-function that a given model has a field called "remoteId". This strategy allows us to ensure that all developers use the appropriate pattern when they add new models in the future. Oh. And its not a build error. Its a runtime-error. |
The error message usually happens because the Annotation processor didn't complete, and you code you posted seems to look fine. Can you post the output of: |
Sure.
"GetMediaType" is a String to enum converter annotated with the @ignore property:
|
Actually. The error occurs in relation to Realm Initialization
The implementation of Repository.java looks like this:
The intention of Repository.java is to withhold a set of common methods like, save() and list() as they are so commonly used. |
Hi @marcel-eggum You can try to use the latest SNAPSHOT from master to see this behavior:
Model classes do support static methods though, so until we can implement custom methods you can do something like this instead:
|
Ah! Thank you @cmelchior. |
I have an app with multidex build enabled. After updating Realm to 0.80.0 it crashes at first request to Realm:
It works fine on 0.79.0. And 0.80.0 works fine in app without multidex. I guess this is related. Clean build does not resolve a problem.
Similar issues: #860, #947
OS: OS X 10.10.2
Android build tools version: 21.1.2
Android gradle plugin version: 1.1.0
JDK version: 1.7
Inspected build logs. 0.79.0 version of Realm annotation processor processes all of my RealmObject classes (I have 14). But 0.80.0 processed only 3 of them - only 3 lines of
Note: Processing class ...
appears in build output.The text was updated successfully, but these errors were encountered: