Joe MooreJoe Moore
Introducing Android IntelliJ Starter and Android CI
edit Posted by Joe Moore on Tuesday August 09, 2011 at 06:33AM

We have been doing quite a bit of Android development over the last year and a half at Pivotal Labs. Over time we have compiled a set of go-to tools, and libraries, and configuration settings that help make our development process as productive as possible. We are excited to publish two open source projects, each with the goal of helping new Android development projects hit the ground running: Android IntelliJ Starter and Android CI.

Joe MooreJoe Moore
Android Tidbits 6/13/2011: Great Expectations
edit Posted by Joe Moore on Tuesday June 14, 2011 at 07:29AM

Great Expectations

Most of our Android projects are using great-expectations, which brings Jasmine-style test assertions. Thanks, Xian, for writing this!

Robolectric Enhancements -- Stay Tuned

We have a bunch of Robolectric enhancements, including the ability to wire up BroadcastReceivers by just declaring them in AndroidManifest.xml. We'll have to put some pull-requests together soon.

Roboguice uses Robolectric!

We use Roboguice on most of our Android projects for dependency injection. We discovered that Roboguice is using Robolectric for unit testing. Awesome!

Roboguice using Robolectric

Tyler SchultzTyler Schultz
Android: Unit testing custom views
edit Posted by Tyler Schultz on Saturday June 11, 2011 at 11:53AM

Android Activity classes can become gigantic and unwieldy if you're not careful. Testing complex Activities requires complex setup. To reduce that pain we try our best to keep the Activity lean. This means getting logic out of the Activity. One technique we use is to create custom views that we can test in isolation.

Joe MooreJoe Moore
Android Tidbits 6/8/2011: Warning! Warning!
edit Posted by Joe Moore on Thursday June 09, 2011 at 10:00AM

Un-shadowed Method Warnings!

In response to yesterday's question about Un-shadowed Method Warnings, Pivot Tyler points out that you can turn these on by calling Robolectric.logMissingInvokedShadowMethods(). Thanks!

Bad cached-robolectric-classes.jar

On two workstations every unit test was failing with the following error:

// …many levels of stack trace, finally:
Caused by: com.xtremelabs.robolectric.bytecode.IgnorableClassNotFoundException: msg because of javassist.NotFoundException: android.content.DialogInterface$OnShowListener
at com.xtremelabs.robolectric.bytecode.AndroidTranslator.onLoad(AndroidTranslator.java:80)
at javassist.Loader.findClass(Loader.java:340)

Cause: there was an old tmp/cached-robolectric-classes.jar that was causing these errors and our tests ran successfully after deleting it. That's two answers from Pivot Tyler!

Don't DDOS Yourself With Your Own App

The Bump Android team wrote an article about a good idea gone wrong. Moral of the story: not all devices behave the same, and this might cripple your servers rather than the devices.

Robolectric Google Group

Join it, contribute, and learn about unit testing your Android apps.

Joe MooreJoe Moore
Pivotal Android Tidbits 06/07/2011
edit Posted by Joe Moore on Wednesday June 08, 2011 at 06:53AM

We're trying an experiment: since we currently have several Android projects at Pivotal Labs, and Android development and testing is hard, we are going to post to the blog the tips, tricks, gotchas, and conundrums we find.

Emulator and Orientation

Android will destroy and recreate activities upon screen orientation change. One way to prevent this is to set android:configChanges="orientation" in your AndroidManifest.xml (article here):

<activity android:name=".activities.MyActivity"
          android:configChanges="orientation"/>

This prevents android from calling onPause() => onDestroy() => onCreate() on a device, but not within the emulator; annoyingly, the Activity is still recreated within the emulator.

Un-shadowed Method Warnings?

Once again we spent about 15 minutes debugging a failing unit test only to find that there was no Robolectric implementation/shadow for one of the Android methods under test (ArrayAdapter#insert in our case). I would be nice to have a "warning mode" where Robolectric would log warning for all un-shadowed methods. I wish we knew the guys who wrote Robolectric…