Tuesday, March 5, 2013

Using ActionBarSherlock with Robolectric 2

Hey everybody! You look great today!

We're getting closer to seamless integration with ActionBarSherlock in Robolectric 2, but it's not quite there yet.

To use the ActionBarSherlock library with our 2.0-alpha-2 release, you'll need to 


5 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. It works fine if we have only a SherlockActivity or SherlockFragmentActivity, but if I add a SherlockFragment to my layout, I get a NullPointerException (described here: https://github.com/pivotal/robolectric/issues/479)

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Which version of ABS should I use? in ABS 4.3 ActionBarSherlock.registerImplementation(ActionBarSherlockRobolectric.class); throws exception.

    java.lang.ExceptionInInitializerError
    at common.v2.BaseRobolectricTestRunner.(BaseRobolectricTestRunner.java:20)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    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)
    Caused by: java.lang.RuntimeException: Stub!
    at android.util.Log.i(Log.java:9)
    at com.actionbarsherlock.ActionBarSherlock.registerImplementation(ActionBarSherlock.java:130)
    at com.actionbarsherlock.ActionBarSherlock.(ActionBarSherlock.java:51)
    ... 19 more

    ReplyDelete
  4. I am getting the same thing as yangcheng above with ABS 4.3.1 and Robolectric 2.0 final. It gets an error while calling Log.i in registerImplementation. Is the above Gist still relevant for Robolectric 2.0?

    ReplyDelete