LinkedIn Open Sources Android Dev Tools
Continuing its policy of contributing to the developer community, LinkedIn this week announced the open sourcing of development tools it uses internally to create Android mobile apps.
Two different open source projects were announced this week, including today's unveiling of Test Butler, designed to improve on problems found in existing Android testing solutions -- specifically unreliable testing environments comprising many moving parts that could fail for a number of reasons.
"We needed a solution that would let us rely on our tests to inform us when there was a problem with the app, not the testing environment," said its creator, Drew Hannay, in a blog post today. "For this reason, we created and open sourced Test Butler, a reliable Android testing tool. LinkedIn runs over one million tests each day using Test Butler and we believe that it can provide a benefit to anyone running Android tests."
Unstable testing environments can result from many factors, Hannay said, some of which can be mitigated by developers, but some of which are more "insidious," having to do with the test devices themselves, or their emulator counterparts.
"If you've ever tried to run a large number of UI tests on Android, you may be familiar with some of the ways the emulator can be unreliable," Hannay said. "Animations must be disabled, so that Espresso tests can run reliably. Tests may fail because the emulator CPU randomly goes to sleep, Wi-Fi turns off unexpectedly, or rogue accelerometer data causes the device to change orientations. If a system app crashes on the emulator in the background, the resulting crash or app-not-responding dialog will cause Espresso UI tests to fail.
At LinkedIn, we've even seen cases where the lock screen on the emulator is randomly triggered, causing tests to fail. This inconsistent behavior was causing our developers to lose trust in our tests and question why we were even writing them in the first place."
That resulting frustration is alleviated by Test Butler in many ways, Hannay said, including:
Signature-level permissions: Test Butler is signed with the system keystore for the stock Android emulator, which means it will automatically be granted any signature-level permissions it requests without the need to grant with ADB [Android Debug Bridge].
- Disable crash and App Not Responding (ANR) dialogs: Since it's a system app, Test Butler can install a custom IActivityController on the emulator and suppress system crash & ANR dialogs from appearing and causing test failures.
- Disable animations: Test Butler handles all the steps of disabling animations with a single line of code in your app!
- Lock screen, Wi-Fi, CPU: Test Butler holds locks on the keyguard, Wi-Fi radio, and CPU to ensure they won't go to sleep and cause test failures.
The tool also lets developers deal with permissions issues, such as enabling/disabling Wi-Fi, changing device orientation, setting location services mode and setting application locale.
Test Butler comes in the form of an Android library for test code and an accompanying Android APK that can be installed on emulators prior to running tests.
Another tool, announced yesterday, is Shaky, for providing app performance feedback to developers. Such feedback is notoriously problematic for numerous reasons, Nick Aversano said in a blog post.
To better help users provide feedback, the Shaky Android library lets them just shake their devices to bring up a form to send along information such as an app screenshot, a log and recent user-visited pages.
"Shaky's API can also be extended to capture even more app-specific information," Aversano said. "With just a few lines of code, developers can get their own feedback reporting flow. This includes the initial dialog, the type of feedback, a screenshot of the app (which users can draw on to show what's wrong), and a submission form that asks the user to describe the bug."
Another homegrown tool that hasn't been open sourced yet but may be heading in that direction is a native video player library for Android.
In yet another LinkedIn Engineering blog post this week, Jack Kwok explained how and why the team built the player.
Using the existing open source Google ExoPlayer code, the team added many of its own refinements and improvements, including memory optimization, data usage optimization (video caching), dynamic bitrate selection and video metrics monitoring.
"We expect to continue to refine and evolve our video architecture to support innovative video use cases and may open source this library if there is enough interest from the community," Kwok said.
While all of this week's announcements are Android-related, that's just happenstance, resulting from a revamp of the flagship LinkedIn mobile app for Android. The company does the same thing for iOS. For example, earlier this month it open sourced Rocket Data, for "faster model management for iOS."
"We actively contribute to the open source community by creating, managing and using open source software," LinkedIn says on the Open Source section of its Web site.
"Our engineering team has open sourced more than 75 projects spanning many categories, including data, frameworks, system operations, testing and mobile," LinkedIn says. "We believe that open sourcing projects makes our engineers better at what they do best. Engineers grow in their craft by having their work shared with the entire community. Several of our open source projects have gained broad adoption and are now part of the Apache Software Foundation."
David Ramel is an editor and writer for 1105 Media.