Google nowadays offered Android KTX, a collection of extensions to assist builders write Kotlin code for Android this is “extra concise, idiomatic, and delightful.” The corporate guarantees to iterate at the API “over the following couple of months” in response to developer contributions and comments.
At its I/O 2017 developer convention in Would possibly, Google introduced Android formally helps the Kotlin programming language, along with Java and C++. Android Studio three.zero with Kotlin toughen adopted in Would possibly.
Lately in preview, Android KTX supplies an API layer on most sensible of the Android framework and Enhance Library — the previous is to be had now on GitHub. Google guarantees to make the opposite portions of Android KTX that duvet the Android Enhance Library to be had in upcoming Enhance Library releases.
To start out the usage of Android KTX to your Android Kotlin initiatives, upload the next on your app module’s construct.gradle report:
After you sync your undertaking, the extensions will seem mechanically within the IDE’s autocomplete record, and opting for any of them will upload the essential import observation on your report.
Google warns that the APIs are more likely to trade all the way through the preview length. In different phrases, builders will have to now not use it of their primary Android initiatives, as there can be breaking adjustments sooner than the strong model arrives. When the API has stabilized and Google commits to API compatibility, Android KTX can be launched as a part of the Android Enhance Library.
Android KTX makes use of package deal names that start with androidx. Google additionally shared nowadays that that is the brand new package deal title prefix for long term variations of Android Enhance Library. The department between android.* and androidx.* is supposed to assist differentiate which APIs are bundled with the platform and which can be static libraries for app builders that paintings throughout other variations of Android.
If you have an interest in offering contributions and comments on Android KTX, take a look at the “Methods to Give a contribution” phase on GitHub.