1

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.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Christine
  • 5,617
  • 4
  • 38
  • 61

2 Answers2

0

The AnnotationDatabaseImpl class is generated by RoboBlender at compile time.

You can specify the following as a Java Compiler Argument ( use your package name )

-AguiceAnnotationDatabasePackageName=some.package.name.here

This should generate the class you need at compile time.

Then in your manifest you need to point to the same package

 <meta-data android:name="roboguice.annotations.packages" android:value="some.package.name.here"/>

For a maven setup reference the answer here:

Injected objects became null after upgrading to Roboguice 3

Community
  • 1
  • 1
mjstam
  • 1,049
  • 1
  • 6
  • 5
  • Ah. I did the thing in the manifest, but not the property. I'll try. – Christine Dec 10 '14 at 23:32
  • But I guess I'll have to switch to Android Studio sooner or later, unfortunately... – Christine Dec 10 '14 at 23:33
  • I added the java compiler argument, I already had the meta-data line in my manifest, but it still won't generate the AnnotationDatabaseImpl file. – Christine Dec 11 '14 at 16:00
  • I did this in Intellij and did a complete rebuild. You should be able to see the class crop up under the generated-sources and in the target classes directory. Without the meta tag it generates a class in the root of the classes directory ( no package name ). – mjstam Dec 11 '14 at 21:06
  • I have switched to Android Studio now (unfortunately), so this issue isn't that important for me any more. – Christine Jun 10 '15 at 20:18
0

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.

Community
  • 1
  • 1
schnatterer
  • 7,525
  • 7
  • 61
  • 80