6

For some reason the RoboBlender does not generate the annotation database. My build.gradle has the following dependencies:

dependencies {
    provided 'org.roboguice:roboblender:3.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.roboguice:roboguice:3.0'
}
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
jush
  • 613
  • 5
  • 13

5 Answers5

4

This is not a final solution, but it can help you. I don't know why, but RoboGuice 3.0 and 3.0.1 throws this exception. What you have to do is disable annotations for databases in your MainActivity as follows:

static {
    RoboGuice.setUseAnnotationDatabases(false);
}

I hope this help

Antonio
  • 11,413
  • 6
  • 34
  • 48
1

Ok, so it seems that since I didn't have any injection in the main class MainActivity it didn't trigger the annotation processing of the inner AsyncTask. Therefore no annotation database was created.

Moreover, it seems that injection in anonymous inner classes is not supported. So the AsyncTask needs to be a proper class (it can still be inside the MainActivity).

I haven't figured out yet how to tell RoboGuice to inspect the inner classes even though the outer one does not have injections.

jush
  • 613
  • 5
  • 13
0

What does the rest of your project structure look like?

Specifically, have you read the RoboBlender wiki

Later versions of Android Studio will, by default, generate a project that falls into the Configuring RoboBlender for a large application using libraries-category.

Fix below does the following:

  1. Rearrange dependencies in build.gradle
  2. Supplies pointer to GuiceModule in project
  3. Rudimentary module for your project


diff --git a/app/build.gradle b/app/build.gradle
index 1e69cec..8450fff 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -34,9 +34,9 @@ android {
 }

 dependencies {
-    provided 'org.roboguice:roboblender:3.0'
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'org.roboguice:roboguice:3.0'
+    provided 'org.roboguice:roboblender:3.0'
 }

 project.tasks.withType(JavaCompile) { task ->
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 017d11e..dba9e49 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -8,6 +8,7 @@
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
         <meta-data android:name="roboguice.annotations.packages" android:value="org.jush.roboguice3test"/>
+        <meta-data android:name="roboguice.modules" android:value="org.jush.roboguice3test.GuiceModule"/>
         <activity
             android:name="org.jush.roboguice3test.MainActivity"
             android:label="@string/app_name" >


package org.jush.roboguice3test;

import android.app.Application;

import com.google.inject.AbstractModule;

public class GuiceModule extends AbstractModule {
    private Application application;

    public GuiceModule(Application application) {
        this.application = application;
    }

    @Override
    protected void configure() {
    }
}
Lasse Magnussen
  • 372
  • 3
  • 8
  • I added the compiler arguments and the meta-data in android manifest. You can find the full project at: https://github.com/jush/RoboGuice3Test The error is still: "Didn't find class "org.jush.roboguice3test.AnnotationDatabaseImpl" on path: /data/app/org.jush.roboguice3test-1.apk" – jush Oct 30 '14 at 21:05
  • ```AndroidManifest.xml``` is missing something like ``` ``` and then your in your project, create that module as well. It could very well be empty. – Lasse Magnussen Oct 30 '14 at 21:13
  • thanks for the suggestion but it didn't help even though I added it: https://github.com/jush/RoboGuice3Test/commit/0726a14e447b81b5fd003fde0f0d03957a96e9e8 – jush Oct 30 '14 at 21:44
  • I tried as you suggested, re-order dependencies and added module constructor with Application parameter and still same error. – jush Oct 30 '14 at 22:04
0

What did you have to do that it did trigger the annotation processing? My main activity has injections. The maina activity inherits from an abstract activity which has as well injections. That abstract activity inherits from RoboActivity.

When i set the roboguice.annotations.packages to roboguice the NoClassFound exception isn't thrown anymore, but i get a NullPointer Exception for the first inject-Object that I wanna use.

I use eclipse to start the app.

When I disable RoboBlender (RoboGuice.setUseAnnotationDatabases(false);) injection works.

LKa
  • 11
  • 4
  • If your activity inherits from RoboActivity then it's a different problem from the one I had. Moreover, you say that if you disable the annotation database then it works. Therefore, the injection is working but the db is not generated. Also I didn't find any way to trigger the injection of the inner anonymous class. I had to move to its own class. – jush Nov 14 '14 at 11:06
  • Does Roboblender even work with Eclipse? I keep getting noclassdeffound on AnnotationDatabaseImpl, the class doesn't get generated. – Christine Dec 09 '14 at 18:52
0

The AnnotationDatabaseImpl is generated at compile time

An explanation is available here

Injected objects became null after upgrading to Roboguice 3

Community
  • 1
  • 1
mjstam
  • 1,049
  • 1
  • 6
  • 5