It’s no secret that the Android SDK has a few rough edges.

Imagine that you’re new to Android and trying to display an image. You’ve already added the image to your res folder and now you need to get a Drawable . You write out resources.getDrawable() only to find it’s deprecated and the function it’s replaced by is only available on Lollipop and above. What do you do if you need to support pre-Lollipop? If you’re like me a few years ago, you end up writing your first (of many) if (SDK_INT >= LOLLIPOP) blocks.

🤦

Ideally, I would know about ResourcesCompat, AppCompatResources, or ContextCompat which act as Utils classes to bridge the gap between platform API changes. However, these classes aren’t nearly as discoverable as having Android Studio autocomplete getDrawable() .

Kotlin extension functions allow for better discoverability and more fluent APIs vs. traditional utils classes by “adding” new methods to existing classes. Android Studio will autocomplete these methods and they aren’t tied to a specific version of the Android platform SDK. Additionally, their implementation can be changed as the platform evolves.

This is why Google recently introduced Android KTX. The set of libraries seek to make the Android SDK more intuitive by leveraging Kotlin language features (such as extension functions).