Note: I published this blog post on The Corner and I am republishing it here to make it available on Medium.

At Square, we rely heavily on automated testing to ensure that our applications work well. Our Point of Sale Android codebase is just shy of 1.5 million lines of code, and we run about 6000 Android instrumentation tests on Firebase Test Lab on every pull request to prevent regressions. This gives our engineers the ability to make deep changes (e.g. migrating from MVP to Workflows) with a lot of confidence.

In this blog post, I share a few utilities…


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

A month ago, my team at Square released the Reader SDK. We had the opportunity to show a demo at Droidcon NYC. How could we make payments cool?

We set up to build SquickPic, a fun Android photo booth: pay a dollar 💳, choose a filter, smile, Snap! 📸 The photo booth prints the picture and tweets it 🐦 (@SquickPic).


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Picture this: a room full of senior Square leads, gathered for an important review meeting. Everyone is looking at their computer, in complete silence, interrupted by bursts of clickety clack. 30 minutes later, the conversation starts.

What is going on? Is everyone waiting for the meeting to start? Are they practicing some form of silent retreat microdosing?

It turns out, this is simply how we work. Alyssa Henry, our VP of Seller, popularized at…


We just released a new version of LeakCanary, and it’s got several new features!

Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Update your build.gradle

Highlight of the leak cause

By determining the expected reachability of objects like Activity and View instances, LeakCanary now highlights the possible causes of the leak with a red underline wave.

We also simplified the leak trace UI and added in context help.


Every month, Square Engineers give lightning talks internally. We just started sharing some of our favorites.

Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Over the last two years, I’ve provided speakers with early feedback on their technical presentations. Eventually, it made sense to compile these tips into their own lightning talk. Here are some pointers on how to create a successful tech talk that will grab your audience’s attention.

I also delivered a more in-depth version of that talk at Droidcon NYC:

What other tricks do you use?


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Dagger 2 is a great dependency injection library, but its sharp edges can be tricky to handle. Let’s go over a few best practices that Square follows to keep mobile engineers from hurting themselves!

Favor constructor injection over field injection

  • Field injection requires the fields to be non final and non private.
// BAD
class CardConverter {
@Inject PublicKeyManager publicKeyManager; @Inject public CardConverter() {}
}
  • Forgetting an @Inject on a field introduces a NullPointerException.
// BAD
class CardConverter {


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

When I received my Google Home, I immediately felt the urge to build something with it. After a good night’s sleep, I had an idea: Baristas and business owners usually have their hands full behind the counter. What if they could complete transactions without tapping buttons at their point of sale? What if a merchant could accept Apple Pay transactions using only their voice?

In the video, we’re using Google Home to activate…


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

Last week, we found an interesting API design issue in the Throwable class of the JDK that led to bugs in RxJava and Retrofit. This is a write-up of how we found those bugs.

Assembly tracking

Monday morning, Nelson Osacky opens a pull request to enable RxJava Assembly Tracking in the debug build of Square Register Android.

Assembly Tracking makes Rx debugging easier by reporting where failing observables were created.

public class RegisterDevelopmentApp extends RegisterApp {…


Heads up, we’ve moved! If you’d like to continue keeping up with the latest technical content from Square please visit us at our new home https://developer.squareup.com/blog

In Square Register Android, we rely on custom views to structure our app. Sometimes a view listens to changes from an object that lives longer than that view.

For instance, a HeaderView might want to listen to username changes coming from an Authenticator singleton:

onFinishInflate() is a good place for an inflated custom view to find its child views, so we do that and then we subscribe to username changes.

The above code…

Py ⚔

Android baker @Square. Twitter account: @Piwai

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store