RoboGuice 3.0 NoClassDefFoundError: AnnotationDatabaseImpl
Asked Answered
N

5

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'
}
Neologism answered 30/10, 2014 at 19:20 Comment(0)
R
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

Resentment answered 13/5, 2015 at 18:18 Comment(0)
N
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.

Neologism answered 31/10, 2014 at 8:13 Comment(1)
were you able to figure this out?Spinning
B
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() {
    }
}
Beatnik answered 30/10, 2014 at 20:28 Comment(4)
I added the compiler arguments and the meta-data in android manifest. You can find the full project at: 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"Neologism
AndroidManifest.xml is missing something like ``` <meta-data android:name="roboguice.modules" android:value="org.jush.roboguice3test.GuiceModule"/>``` and then your in your project, create that module as well. It could very well be empty.Beatnik
thanks for the suggestion but it didn't help even though I added it: github.com/jush/RoboGuice3Test/commit/…Neologism
I tried as you suggested, re-order dependencies and added module constructor with Application parameter and still same error.Neologism
P
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.

Pierson answered 14/11, 2014 at 9:47 Comment(2)
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.Neologism
Does Roboblender even work with Eclipse? I keep getting noclassdeffound on AnnotationDatabaseImpl, the class doesn't get generated.Sudorific
A
0

The AnnotationDatabaseImpl is generated at compile time

An explanation is available here

Injected objects became null after upgrading to Roboguice 3

Apospory answered 10/12, 2014 at 19:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.