NoSuchMethodError: roboguice.inject.ContextScope: method <init>()V not found

108 views
Skip to first unread message

glenviewjeff

unread,
Oct 17, 2011, 11:44:07 AM10/17/11
to robo...@googlegroups.com
I'm trying to run my Robolectric test now that I migrated it to Roboguice 2.0 beta 1.  I'm getting the following error:

java.lang.NoSuchMethodError: roboguice.inject.ContextScope: method <init>()V not found
    at roboguice.RoboGuice.createNewDefaultRoboModule(RoboGuice.java:124)
    at com.mydomain.myapp.android.activities.myactivity.InjectedTestRunner.createApplication(InjectedTestRunner.java:26)
    at com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:278)
    at com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:221)
    at com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:201)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Here's what my test setup looks like:

public class InjectedTestRunner extends RobolectricTestRunner {
...
    @Override protected Application createApplication() {
        OpenHelperManager.setOpenHelperClass(AndroidDatabaseHelper.class);
        MyApplication application = (MyApplication)super.createApplication();
        RoboGuice.setApplicationInjector(application, RoboGuice.DEFAULT_STAGE, Modules.override(RoboGuice.createNewDefaultRoboModule(Robolectric.application)).with(new MyModule()));
        return application;
    }

    @Override public void prepareTest(Object test) {
        MyApplication myApplication = (MyApplication) Robolectric.application;
        Injector injector = RoboGuice.getApplicationInjector(myApplication);
        ContextScope scope = injector.getInstance(ContextScope.class);
        scope.enter(myApplication);
        injector.injectMembers(test);
    }
}


Michael Burton

unread,
Oct 17, 2011, 2:36:02 PM10/17/11
to robo...@googlegroups.com
Are you mixing jar files?  My ContextScope in 2.0b1 has a default constructor




--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To view this discussion on the web visit https://groups.google.com/d/msg/roboguice/-/oNjYUY48UqUJ.
To post to this group, send email to robo...@googlegroups.com.
To unsubscribe from this group, send email to roboguice+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/roboguice?hl=en.

glenviewjeff

unread,
Oct 17, 2011, 6:27:16 PM10/17/11
to robo...@googlegroups.com
Ugh, yes.  If I had a dollar...
Reply all
Reply to author
Forward
0 new messages