realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.46k stars 1.75k forks source link

Compile Error #2274

Closed carotorrehdz closed 8 years ago

carotorrehdz commented 8 years ago

Every now and then, when I try to run my app Android Studio throws an error in the Message Gradle Build section that says that one of my model classes couldn't be added to the module. It also says the message that only classes extending RealmObject can be added. I'm positive that my model class extends from RealmObject and the next time I try to run it it works perfectly. Not sure what is going on and just wanted to let you know.

screen shot 2016-02-12 at 11 27 56 am

Thanks for all your hard work!

emanuelez commented 8 years ago

It's hard to diagnose the issue without more information. Here are a coupleof questions that can help us figure things out.

Do you define a custom module or are you relying on de default one? Do you use any library that in turn uses Realm? What version of Realm are you using? What version of the Android Gradle plugin?

carotorrehdz commented 8 years ago

@emanuelez Yes, I do define a custom module. I'm using realm version 87.0 and Android Gradle plugin version 1.5.0. And regarding the question of libraries that use Realm not sure if I can answer that question correctly, but here it's my dependencies part of my app build.gradle

screen shot 2016-02-15 at 10 09 07 am

cmelchior commented 8 years ago

It looks like you have incremental compilation turned on. It doesn't work well with libraries like Realm and Dagger2 currently: http://stackoverflow.com/questions/34989984/dagger-2-sometimes-on-compiling-i-get-cannot-find-symbol-class-daggerapplicati

cmelchior commented 8 years ago

You can also see this Dagger 2 issue that discuss the problem: https://github.com/google/dagger/issues/298

carotorrehdz commented 8 years ago

Thanks @cmelchior and @emanuelez! I'll turn off incremental compilation and I'll see if this error doesn't happened anymore.

beeender commented 8 years ago

@caroth92 Good to hear your problem is solved. I am closing this issue now. Thanks for the feedback!