Search code examples
androideclipseroboguice

RoboGuice, RoboBlender and Eclipse


I use RoboGuice 3.0 alpha-2, have been doing so for quite a while, and I'm happy with it. Now I wanted to upgrade to RoboGuice-3.0 or -3.01, but that I can't get to work.

I use Eclipse (I use Android Studio in some project but I really don't like it), RoboBlender complains about AnnotationDatabaseImpl not being there. When I disable Roboblender, I get

E/AndroidRuntime(18825): FATAL EXCEPTION: main
E/AndroidRuntime(18825): java.lang.NoClassDefFoundError: com.google.inject.internal.util.$Maps
E/AndroidRuntime(18825):    at com.google.inject.assistedinject.BindingCollector.<init>(BindingCollector.java:34)
E/AndroidRuntime(18825):    at com.google.inject.assistedinject.FactoryModuleBuilder.<init>(FactoryModuleBuilder.java:206)
E/AndroidRuntime(18825):    at com.loqli.android.robo.GossipModule.configure(GossipModule.java:260)
E/AndroidRuntime(18825):    at com.google.inject.AbstractModule.configure(AbstractModule.java:78)
E/AndroidRuntime(18825):    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:252)
E/AndroidRuntime(18825):    at com.google.inject.spi.Elements.getElements(Elements.java:107)
E/AndroidRuntime(18825):    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:135)
E/AndroidRuntime(18825):    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
E/AndroidRuntime(18825):    at com.google.inject.Guice.createInjector(Guice.java:100)
E/AndroidRuntime(18825):    at com.google.inject.Guice.createInjector(Guice.java:87)
E/AndroidRuntime(18825):    at roboguice.RoboGuice.createGuiceInjector(RoboGuice.java:186)
E/AndroidRuntime(18825):    at roboguice.RoboGuice.getOrCreateBaseApplicationInjector(RoboGuice.java:151)
E/AndroidRuntime(18825):    at roboguice.RoboGuice.getOrCreateBaseApplicationInjector(RoboGuice.java:90)

I moved back to alpha-2, but now I wonder, should RG and RB work with Eclipse and ant?

Edit: I mentioned "Eclipse". I'm not interested in how it works on Android Studio, I want to know how to make it work in Eclipse.


Solution

  • The correct way in eclipse would be to set RoboBlender up as annotation processor. It didn't get this to work, though (see bellow).

    Maven - working solution

    Here's how I got it working - using Maven. Maven generates the Annotation Database to target\generated-sources\annotations. So I simply added this path as source folder in eclipse and voilà no more java.lang.ClassNotFoundException: AnnotationDatabaseImpl!

    Ant - similar solution?

    From your question I presume you're using ant?! Maybe you can set up the annotation processing with ant instead of maven?

    Eclipse annotation processor - a further approach

    As mentioned, I first tried to use eclipse annotation processor and almost got it working. I added RoboBlender and its transitive dependencies to the Factory Path. For RoboBlender 3.0.1, this is

    1. RoboBlender, its dependency
    2. velocity and its dependencies
    3. commons-collections and
    4. commons-lang.

    Because I use multiple modules with annotation databases, I add the Processor Option guiceAnnotationDatabasePackageName.

    This resulted in an info message in my eclipse error log that said Impossible to generate annotation database., which is exactly the message of the generic exception thrown by the RoboGuice's AnnotationDatabaseGenerator. EclipseErrorLog Unfortunately, there are no stacktraces or anything, so I gave up here and found the solution using maven as stated above. Maybe someone else can find the missing piece here?
    If it helps you can find the project where I use RoboBlender here.