Modern Android Development after Google I/O 2018 | KISS digital

When she was a little girl she pictured herself as a geologist or an oceanographer, but then, somehow, she pursued a master’s degree in Italian philology.

Modern Android Development after Google I/O 2018

Post-Google I/O 2018 Modern Android App Development

The year is 2018. It's the middle of May. Wherever you move, you see kids in white first communion robes riding their brand new hoverboards or flying drones, your mom "pings" you on one of the messaging apps asking whether you've seen her new photo on Instagram, and although you really don't mean to, you can't help but overhear your significant other discussing whether he/she should sell or #hodl on to his/her crypto.

You think to yourself "whoa, ain't technology a bliss", and then you also think "oh, but the Fragment API, tho".

Fortunately, there are a lot of people working on keeping your technology enthusiasm intact. For Android developers, surely one of the ways to achieve that is by liberating you from the boilerplate code and architectural compromises you're supposed to take to make your Android app work.

I am not going to focus on what's new in Android P, instead, I'll do a quick recap of what new tools and techniques a "modern" Android developer should be aware of.

"Modern" as heard of in this Chet Haase and Romain Guy's talk. If you're only going to watch one talk from the whole Google I/O 2018 Android track, then I suggest this be the one.

Tools

Android Jetpack

tl;dr: Android Jetpack "is a set of libraries and guidance for modern Android Development", as in "a bundle of docs and libraries you already know (or at least heard of) and probably love, plus the Navigation part". Comprised of components in 4 key areas of Android development: Foundation, UI, Architecture, Behaviour, it's job is to accelerate the tedious parts of Android app development, so instead of focusing on the fragment lifecycle diagram again, you can focus on parts of your app that you actually get a kick from.

Why do I think this is cool? Well, for a long time the Google Android team wasn't very into giving us architectural guidance. They were more like "if it works for you, then it's ok", and while I generally admire this kind of attitude, I do think that a clear set of best practices never hurt no one.

How to start using Jetpack? Well, after learning about Jetpack, I went "ok, this looks promising, so how do I download it", but you can't really download a mindset, right? Similarly, you don't "download" Jetpack. It's right there, in your freshly updated Android Studio 3.2, waiting for you to stir some action. Just create a new project, and choose Activity & Fragment + ViewModel template. It will generate three stub classes for you, namely StartActivity, StartFragment and StartViewModel (oh, ViewModel... the last year's Architecture Components addition, that's supposed to take care of the stateful data for your activities and fragments - it dies when they die, but no sooner, IYKWIM). From there, if your app contains more than one screen, you should implement some kind of navigation, which is now easier than ever before, with the aptly named, debuting Navigation component. Then, knock yourself out with the help of the remaining Architecture Components, such as LiveData, Room and Lifecycle-Aware Components.

PagingLibrary

You should definitely have a look at PagingLibrary that makes gradual loading of your data into RecyclerView much easier and lets you react to data changes using LiveData or RxJava2.

WorkManager

This Jetpack component helps with scheduling background jobs. Why do we need it, and more importantly - why do we need it right now? I could try but I wouldn't be able to explain it better than Yonatan W. Levin in his article. Basically, with Android platform changes aimed at optimizing battery running time, you cannot rely on background Services anymore. WorkManager largely simplifies the updated process of managing background tasks. To quote Levin:

No more complex JobSchedulers/JobDispatcher/Greed Executors boilerplate code. You create a work, schedule it and it gets done. Simple as that.

Android Studio

I always say that I am not a fangirl of any particular technology but I just realized that there's this one product that I am a sucker for. And it's Android Studio. I sometimes wonder if I can program at all or is it the IDE (and StackOverflow obviously) that does everything for me. I cannot even keep up with all the cool additions that seem to be an endless stream of awesome for Android developers. To name just a few, and just the ones announced at this year's I/O, that will be available starting with Android Studio 3.2:

Here's a comprehensive list of all the new features.

What's to come: Motion Layout designer, that will make designing animations a breeze.

Material Design

Material Design got revamped, too. If you like to design your own apps, you should be getting familiar with the new Material Theme Editor. If you're using Sketch to do so, you can even download the Material Plugin. There are also some codelabs on how to integrate Material Design into your Android app, both for Java and for Kotlin.

Techniques

Fragments And Single Activity Good

Apparently, Fragments are in, again. Admittedly, I kind of missed the period they were out (as opposed to what, exactly? My hipster radar must have been so off this entire time), but yes, yes, by all means, you can now use Fragments and still be a cool kid (ideally, your modern Android app should consist of one Activity and multiple Fragments, but the vibe of "whatever works for you" is still strong). Phew.

Enums Good

Heck, now you can even use enums, and still not be considered a fossil (thanks, performance-optimized ART, and so long, size-optimized Dalvik!).

RelativeLayout Not Good

Drawing on the aforementioned Haase and Guy's talk, here's a short list of Android layouts that don't suck:

Put simply, the rest of them suck, so avoid using them.


Of course that's not all there is, I didn't mention Android KTX, Testing, Android Wear/TV/Auto, ARCore and probably some more tools and components at all. If you're hungry for more, here's a playlist with all the Google I/O Android announcements.

Lidia

When she was a little girl she pictured herself as a geologist or an oceanographer, but then, somehow, she pursued a master’s degree in Italian philology. She still loves languages, but you all know how awkward talking to people gets sometimes, so she decided to start talking to computers instead.