I made an Android app for Buddybuild

Posted by Romain Pouclet on May 7, 2017

I bought a Nexus S a few years ago. It was a more than decent upgrade from my Blackberry Bold and I used it for a year. I even started dabbling with mobile development before moving to Montréal. Last week, I made an application for Android.

TL;DR: The application is available on Github and will keep evolving as I’m learning.

Why

I joined buddybuild 3 months ago. Besides writing, coding and making awesome T-shirts, I helped users with their projects. Most of the issues with Android were simple enough to handle on my own. When they were too complex, I forwarded them to our Android experts. One can’t know everything but I’d wanted to learn about the Android platform for a while. That’s why I figured it would be interesting to start and write about the experience.

I didn’t start making an app right away as I figured learning about the tools would be enough. I tried to follow outdated tutorials and random StackOverflow answers. Getting started with Android was painful.

The thing is, if you expect to learn by googling “install APK command line Android help”, you’re in for a rough start. I figured I should start learning from the beginning.

Before we dig in, note that I’m not giving up on iOS. I use an iPhone as my daily phone and Swift still is the language I’m having the most fun with. That said, working for buddybuild - a product that I love - made me want to know more about the platforms we support. I do think this experience will make me a better evangelist.

The tooling

Getting started with Android development was easy. I installed Android Studio and bothered my friend Marcos a lot with random questions. The first thing I did was following the “Hello World” tutorial. Since I already knew gradle, java and what an Activity was, it didn’t take me long to go off track. This tutorial was a great starting point, though.

The tooling is far more superior for Android that it is for iOS. While I do think that Android Studio (and Java GUI in general) is ugly, Xcode is far behind.

Android studio works great with gradle. Add a dependency or change the SDK version and it will suggest you to perform a sync. I would love to see something similar happening with Xcode and the Swift package manager. I used Java a lot in the past so I already knew the refactoring tools were amazing. I was able to iterate by moving things around without worrying of breaking my project.

List of commits on Ultron

The libraries

I decided to write an Android application for buddybuild. Using our public API, I wanted to list my apps and be able to trigger a build. Marcos (again, thank you!) suggested to use Retrofit, a library from the people at Square. I created a Buddybuild client in 20 lines of code (18 of which being good old java annotations) in a few minutes.

package buddybuild.com.ultron.model;

public interface Buddybuild {

    @GET("apps")
    Observable<List<App>> apps();

    @GET("apps/{app_id}/builds")
    Observable<List<Build>> builds(@Path("app_id") String appId, @Query("limit") int limit);

    @FormUrlEncoded
    @POST("apps/{app_id}/build")
    Observable<Build> trigger(@Path("app_id") String appId, @Field("branch") String branch);

}

A few days later, I’m using Retrofit to make HTTP calls and Moshi to parse JSON. I used Butterknife to bind my components to my activities and I, of course, made the Switch to RxJava. As a general rule, I tend to avoid adding dependencies to achieve things I’m not able to write myself. In this context, I bent it a little: did I need to learn how to perform an HTTP call? Probably not. I got a glimpse of what a real-life Android project looked like and it made the experience better.

The language

Java was my first Object-Oriented language. 10 years later, I’ve tried enough languages to mention that Java is far from being my favourite. While Java 8’s lambdas are cool, I didn’t have much fun. Hopefully, Kotlin will fix that.

The UI

I didn’t put much attention into the design of my app: a successful build is “bright green” and a failed one is “unreadable red”. The documentation about material design looked amazing though. This and using an Android cellphone as my main device for a while should help getting a better understanding of what’s expected in an Android app.

My Android app

Conclusion

This is the result of my first week doing Android Development. I’ll update it as I go along. In the meantime, the application is available on Github and will keep evolving as I’m learning.