Google Working On (Even) Better Kotlin Support For Android

Google is working to make coding in Kotlin for Android a much easier task through the creation of a new set of extensions meant to simplify some of the most commonly used code. The extensions, which are packed away in an API called Android KTX, are currently in preview mode and there's no timeframe set for a full stable release as of this writing. However, based on some of the examples provided by Google on the Android Developers site and represented in the video below, this is definitely going to be something developers who use the language want to check out. Documentation is also already available on the company's GitHub repository so anybody interested in contributing to the project or just seeing what's been included so far will want to head over to the source link below.

For those who may not already be aware, Kotlin is a programming language introduced way back in 2011 that runs in a Java Virtual Machine. It has been available for use in Android since the beginning through the use of add-ons but has only been officially supported since last year. This latest effort really serves to deepen the integration between Android development and Kotlin. It should make the platform more comfortable and be more welcoming to both those who already use the language and for those who are just starting out. For now, the main draw appears to be in the simplification Google is bringing to Android KTX. Perhaps the most striking current example the company provides is some code intended to trigger a given action with a View's onPreDraw callback. The standard format in Kotlin would require no fewer than six lines of code, starting with a PreDraw listener and ending with the action and a return. As long as the Android KTX library has been instantiated, however, the new API only requires a single line - namely, "view.doOnPreDraw { actionToBeTriggered() }."

Of course, it goes without saying that the new API is officially supported in Google's dedicated Android development software. That also means that once Android KTX is implemented into a project, its extensions will be added to the IDE's autocomplete lists. Meanwhile, Google is also implementing changes into package names to help differentiate between projects that use KTX and those that don't; Android KTX project package names will begin with "androidx" rather than just "android."

You May Like These
More Like This:
About the Author
2018/10/Daniel-Golightly-2018-New.jpg

Daniel Golightly

Senior Staff Writer
Daniel has been writing for AndroidHeadlines since 2016. As a Senior Staff Writer for the site, Daniel specializes in reviewing a diverse range of technology products and covering topics related to Chrome OS and Chromebooks. Daniel holds a Bachelor’s Degree in Software Engineering and has a background in Writing and Graphics Design that drives his passion for Android, Google products, the science behind the technology, and the direction it's heading. Contact him at [email protected]
Android Headlines We Are Hiring Apply Now