Realm-java: Improve error-message for duplicate models "attempt to recreate a file for type io.realm.<GeneratedProxyClass>"

Created on 22 Dec 2014  Â·  9Comments  Â·  Source: realm/realm-java

I get this erorr while building the project.

First-Good-Issue O-Community T-Enhancement

Most helpful comment

I had another model class with the same name in another package.

All 9 comments

Can you please detail what you attempt, detailed log and how you have tried to debug it?
Thanks

I created a model class by extending the RealmObject class. While building the project I get the error

Error:(8, 8) error: Attempt to recreate a file for type io.realm.NotificationModelRealmProxy
Note: Processing class UserModel
Note: Version 0.76.0 of Realm is now available: http://static.realm.io/downloads/java/latest

Nevermind. Got it.

I had another model class with the same name in another package.

Happy you got it solved.
I'll change the title into an enhancement suggestion. Maybe we could make that error message more clear.

A check for existing classes with the same name should be added here: https://github.com/realm/realm-java/blob/master/realm/realm-annotations-processor/src/main/java/io/realm/processor/RealmProcessor.java#L172 and an appropriate error thrown

In my case, this was caused because IntelliJ generates sources to out while Gradle generates it to build. However, IntelliJ then marked Gradle's generated sources folder as "source folder". So when compiling, it now ended up having those sources twice.

I haven't investigated yet why this happens and how to avoid it, but a quick fix is to delete the generated sources in the build directory.

This should have been fixed. Model classes are embedding the package name as part of the name for the class, so no collisions should be possible unless it would also crash the Java compiler.

➤ Unito Sync Bot commented:

Transition made by Unito

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cmelchior picture cmelchior  Â·  3Comments

wyvern610 picture wyvern610  Â·  3Comments

harshvishu picture harshvishu  Â·  3Comments

CNyezi picture CNyezi  Â·  3Comments

Frasprite picture Frasprite  Â·  3Comments