RoboGuice Error: Didn't find class "AnnotationDatabaseImpl" on path

250 Views Asked by At

Trying to get a simple app to run with roboguice but encountering this error: Didn't find class "AnnotationDatabaseImpl" on path: Looks like a lot of people get this error, and none of the solutions seem to work for me. All I have done is taken the AndroidStudio blank app template. MainActivity.java:

package com.example.temp.robotest;

import android.os.Bundle;

import roboguice.RoboGuice;
import roboguice.util.RoboContext;
import java.util.HashMap;
import java.util.HashMap;
import java.util.Map;
import com.google.inject.Key;
import roboguice.activity.RoboActionBarActivity;

public class MainActivity extends RoboActionBarActivity implements RoboContext {

    protected HashMap<Key<?>, Object> scopedObjects;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public Map<Key<?>, Object> getScopedObjectMap() {
        return this.scopedObjects;
    }
}

And my gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.temp.robotest"
        minSdkVersion 23
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'org.roboguice:roboguice:3.0'
    provided 'org.roboguice:roboblender:3.0'
}

Replacing line 14 in MainActivity.java with //public class MainActivity extends AppCompatActivity implements RoboContext { and the app runs. But I wish to use roboguice. Any thoughts?

1

There are 1 best solutions below

0
On

Replacing provided 'org.roboguice:roboblender:3.0' with apt 'org.roboguice:roboblender:3.0' worked for me.

You have to enable the com.neenbedankt.android-apt gradle plugin by adding

apply plugin: 'com.neenbedankt.android-apt'

to your build.gradle from the app module and

    buildscript {
    /.../
        dependencies {
            /.../
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        } 

    }

to your build.gradle of the project.