In the past months, Google has created a series of videos and articles named MAD Skills (Modern Android Development Skills) to teach developers how to use the latest technologies in the Android ecosystem to create better applications.
Truth be told, Android development has changed a lot in the past years. From the announcement of Jetpack in Google I/O 2018 to the Kotlin-first approach at Google I/O 2019 and Jetpack Compose on the horizon, things have evolved a lot for the better. Even though we are continuously investigating and applying new technologies to our projects, it might be difficult for new developers to learn how to play with all these new toys, and/or for seasoned developers to catch up. This is why we love the idea behind this video series as much as the Android Development Team at Google loves to use puns whenever they can.
Let's take the opportunity to talk about some of the topics that have already been covered in this ongoing series, as well as adding some more technologies that we have also found useful in our Android development across the years.
Series topics covered so far
- App Bundles: In the past, every Android application consisted of a single universal APK which was installed on all devices. This was simple, but very inefficient since all devices received the entire set of code and resources even if they were never going to use it. As a result of this, APKs ended up being much bigger than what they needed to be, which in turn, ended up consuming much more of their users precious storage space.
Bigger APKs = More chances that your users uninstall your app once they need the storage in their devices = Less user retention = Unhappy developers
App Bundles, Android's new official publishing format, allows developers to defer the APK generation and signing and let the Play Store handle it. Instead of uploading an APK, developers are requested to upload a new .aab file which is used by the Play Store to generate APKs for every user that tries to download the app. These APK are tailored to each device your users own, and only contain the code and resources they need. This can result in the generated APKs being as small as 50% of the original universal APK size.
One thing to notice, is that, since these APKs are generated on demand, you have to opt in to App Signing in the Play Store, instead of manually signing your APK as we used to do in the past. This makes the entire process more secure and prevents old problems such as losing the keystore file, which was a catastrophe in itself. Don't worry, it should not require a lot of effort to migrate your app from the old way to this modern approach since Google provides many options to opt-in, be it for new apps or existing apps that used to manage signing locally.
Another important factor to take into account is that Google has already announced that App Bundles will become mandatory for new app updates/submissions sometime in the middle of 2021. So, if you have not migrated your app distribution to use App Bundles yet, we strongly suggest you do so now to avoid any surprises in the future.
- Kotlin: Official support for the Kotlin language on Android was announced back in Google I/O 2017, and since then, the community has been lovin' it. So much so, that Google announced that they will be taking a Kotlin-first approach when developing their own libraries at Google I/O 2019.
We have already been using Kotlin for years now and the advantages it offers when compared to Java are mind-boggling. Needless to say, we have been suggesting it for new projects all that time, while also migrating (sometimes slowly but surely) all our old projects in Java to Kotlin. Its concise syntax, ease of use and extensibility has significantly sped up our development while allowing us to deliver more robust and bug resilient code.
Here are just a few of the many Kotlin features we love:
- Coroutines: Allow us to run asynchronous code in a much more elegant and lightweight way than its previous RxJava counterpart. Now that StateFlow has been added into the mix, there is even debate on whether or not LiveData is even necessary anymore.
- Extension Functions: Not only has the Google team work on a lot of extensions that help all developers save time and write more concise code (Android KTX), but we have also found ourselves extending 3rd party libraries and platform classes to great success.
- Null Safety: As a long time Android developer, you should know that NullPointerException was probably one of the most common crash causes of apps in production. That is now a thing of the past since nullability checks are enforced in the language itself.
- Material Design Components: The Material Design Guidelines have been around since the inception of Android 5.0 Lollipop, back in 2014. These guidelines, components and tools allow developers and designers to come up with apps that look and feel familiar for their users while following best practices. Back then, these were just guidelines and the implementation of most components was up to the developer to make. This has changed a lot, since the Google team has been continuously adding more and more component implementations that are ready to use out of the box.
Material Design Components also have native support for Dark Theme, which has allowed us to easily enable this feature for our users. Dark Theme is specially important nowadays since it is not only healthier for the user's eyes, but it also helps save a lot of battery in devices with OLED displays.
- Motion Layout: Allows you to easily build amazing animations. Built on top of ConstraintLayout, it lets you define different sets of constraints for your layouts and manage the transition between each constraint set, resulting in animations that were previously very difficult or nearly impossible to create. As of version 4.0, Android Studio includes a Motion Editor that makes it extremely easy to create and manage motion animations using MotionLayout.
- Navigation: Long gone are the days of manually handling FragmentManager transactions (at least 99% of the time). Jetpack's Navigation Component has helped us to easily build complex navigation flows while also managing deep links across our apps. Being long time iOS developers, we love to be able to see an entire flow of the app at first glance in Storyboards and the Navigation Graph does exactly that for Android. Safe Args are a neat bonus that avoids the need of defining a contract between fragments / activities ourselves, while enforcing type and nullability checks in arguments passed between destinations.
Allow us to share a tiny tip for a problem you might encounter when integrating the Navigation Component in your project. BottomNavigationView is becoming more and more common on Android Apps and chances are, your application has one. The need for handling multiple back stacks (one for each item of the Bottom Navigation) natively in the Navigation Component is a common ask from Android Developers in the community. Even though native support has been teased in pretty much every live Q&A with the UI Toolkit team, it is yet to come. However, this does not mean that you can't use Bottom Navigation with the Navigation Component, there is a workaround posted in the official Architecture Components Sample repository that we recommend, and have been using ourselves, in the meantime.
We are sure that the Google Team will continue to add more topics to these series. They have already teased a series on WorkManager and Room for the future, and more Jetpack libraries will certainly follow.
Tracking your MAD score
Google has also created a special plugin for Android Studio that generates your own MAD Scorecard. This plugin collects anonymous data from your Android Project and scores it based on how many Modern Android Development Skills you have successfully integrated in it.
Gamification is something that we have always loved, so we gave it a try! You can check how we scored in one of the projects we are currently developing following this link. What can we say? It seems we are quite mad when it comes to Android development (pun intended).
Android development has evolved a lot in the past years and even more exciting changes are yet to come. Sometimes change can feel overwhelming, but fear not, all changes are for the better. The Android Development team is working hard to make Android development easier and faster, allowing developers to build better apps.
At CodigoDelSur, we embrace the change and are genuinely excited to see what is to come. We also strongly recommend all Android Developers to do the same, all changes we have integrated on our development process have helped us improve enormously. The learning curve can be steep but the reward more than makes up for it. So if you haven't already, go check the entire Youtube Series, as well as all other resources the Android Team has been creating. Here are just some examples: