Now in Android: January 23, 2020
AndroidX releases, Android Studio 3.6 and 4.0 previews, Kotlin typealias, building a Kotlin extensions library, and two Android podcast episodes
--
Welcome to Now in Android, your ongoing guide to what’s new and notable in the world of Android development.
Now in Android: The Video Version
The content in this article is also covered in this handy video. Feel free to watch it, or ignore in and keep reading below.
AndroidX Releases
When I first drafted this AndroidX section, earlier this week, there weren’t many library updates. I figured it made sense: people were just getting back from the long holiday, probably learning how to type again, and not a lot had changed since December.
Boy, was I wrong.
January 22nd hit, and a ton of libraries were released. Check out the details on the AndroidX releases site, but here are some of the highlights.
First, many libraries went stable, including:
- Fragment 1.2.0 introduces FragmentContainerView as the recommended container for fragments, integrates in Lifecycle ViewModel SavedState, and fixes timing issues with
onDestroyView()
when using animations/transitions. - Lifecycle 2.2.0 has the new
lifecycle-runtime-ktx
artifact with Kotlin coroutine integration, plus greater integration into the existinglifecycle-livedata-ktx
artifact for coroutines. - Lifecycle-Viewmodel-Savedstate 1.0.0 is the first release of this library. ViewModels can now participate in
onSaveInstanceState()
via the new SavedStateHandle class without the boilerplate of overriding and handling saved state manually in your Activity/Fragment. See the docs for more information on this new library. - Navigation 2.2.0 provides navigation graph-scoped Lifecycles and SavedState with the new
NavBackStackEntry
, query parameter support for deep links, and improved animation support. - WorkManager 2.3.0 has new
setProgress()
andsetForeground()
APIs, which allow you to communicate progress as your Worker runs, as well as allowing a Worker to run in a foreground service when necessary.
Also going stable recently were Activity 1.1.0, SQLite 2.1.0, and Transition 1.3.0.
Various AndroidX libraries also hit alpha, including these two which just reached their first alpha milestone:
- Browser 1.3.0-alpha01: Features include passing free-form commands to a trusted web activity via TrustedWebActivityServiceConnection#extraCommand and nullability for CustomTabsSession#mayLaunchUrl.
- Heifwriter 1.1.0-alpha01 This library offers the ability to write High Efficiency Image Format (HEIF) files from one or more input images. The 1.1 release offers minor improvements and fixes.
Android Studio 3.6 and 4.0
If you want to play with in-development features for Android Studio, head on over to the Preview site to download one of the pre-stable versions.
Android Studio 3.6 had its first RC release in December, as it gets ready to go stable sometime soon. Be sure to check out this release for a new split-view editor for seeing both design and code views of your UI, easier leak detection with the memory profiler, and the new View Binding feature which eliminates the need for findViewById()
.
Meanwhile, Android Studio 4.0 recently launched its ninth canary build. Maybe you need a more stable build for your everyday usage, but check out 4.0 if you want to play with any of the new features it offers, including the MotionLayout visual editor, support for Jetpack Compose, the enhanced layout inspector, a new CPU profiler UI, a new build speed visualizer, new templates for fragments, and new Kotlin DSL scripting for gradle build files.
New article series: Kotlin Vocabulary
Florina Muntenescu has started a new series of articles on the Kotlin language, Kotlin Vocabulary. This first article in the series covers the typealias
language feature, which can be used to simplify or shorten long type names. For the C/C++ programmers in the house, typealias
is similar to (an alias for, you might say…) typedef
, allowing you to define an alternate way of referring to some type in your code.
The article also talks about import aliases, as well as some of the reasons why typealias
may not be the right solution in some situations.
The series is just starting and Florina’s looking for ideas of other interesting features to cover. If you have any favorites you’d like to see her dive into, head over to her Twitter thread and add a suggestion.
Codelab: Building a Kotlin Extensions Library
Wojtek Kaliciński released a new codelab that shows how you can use the same approach the Android team did to create Android KTX for building your own library of handy extensions in Kotlin. For example, you’ll learn how to convert an existing asynchronous callback API into one that uses coroutines, using either suspend functions or Flow.
Podcast Episodes
There’s been a new episode of Android Developers Backstage since the last Now in Android. Check it out at the link below, or in your favorite podcast client:
ADB 131: Jetpack Compose and Declarative UIs
In this episode of Android Developers Backstage, Tor, Romain, and Chet talk with Adam Powell from the UI Toolkit team about Jetpack Compose. The conversation meandered into declarative programming, “dynamic declarative,” reacting to state changes, data flowing through an application, and Kotlin domain-specific languages.
Fragmented 187: Coroutines
Also in the world of Android podcasts, the Fragmented podcast recently hosted Manuel Vivo and Sean McQuillan for Episode 187: Coroutines, in which they talk about (wait for it…) coroutines!
Now then…
That’s it for this time. Go play with the latest AndroidX library releases! Check out Android Studio 3.6 and 4.0 features! Go Read about Kotlin type aliasing! Build a Kotlin extensions library! Listen to the latest ADB and Fragmented podcast episodes! And come back here soon for the next update from the Android developer universe.