Zhuinden / realm-monarchy

[ACTIVE-ISH] A wrapper over Realm which exposes it as LiveData, managing Realm lifecycle internally.
Apache License 2.0
88 stars 11 forks source link

Program type already present #17

Closed squirtle1990 closed 6 years ago

squirtle1990 commented 6 years ago

I added this library to an existing project that uses realm.

When building, I receive a "Program type already present: io.realm.BaseRealm$2" error.

I've checked my realm plugin version to match the outdated 5.1.0 bundled in the latest source.

Tried cleaning, rebuilding, deleting .gradle and .idea, but no success.

Thanks, Tim

Zhuinden commented 6 years ago

Hrmm :/ technically I'm just applying realm-android plugin, but maybe that can cause quirks?

But I also didn't want to go with the stetho-realm route where they added Realm as compileOnly and then it's on you to actually add Realm.

I'm not sure why you are getting this error and that makes it hard to fix. I could try re-releasing a new version where I add realm dependencies manually with api dependency.....

In the meantime if you're in a hurry, you can try cloning out the repository and copy the com/zhuinden/monarchy sources into your project, just like how I used to use AutoValue. If that works, at least I'll know that the quirk is in the Realm Gradle Plugin.

(Any version that is Realm-Java 5.0.0 or higher should work with latest version of Monarchy.)

Zhuinden commented 6 years ago

Any luck? I cannot verify the cause as I haven't been able to reproduce this.

squirtle1990 commented 6 years ago

I followed your instruction to copy the com/zhuinden/monarchy sources into my project.

The project compiles now. So this means, like you were saying, the issue is a quirk with the realm gradle plugin.

If you switched to compileOnly for the realm plugin like stetho-realm, it might be a good idea to specify in the docs the support realm versions.