Did you miss a session from GamesBeat Summit Next 2022? All sessions are now available for viewing in our on-demand library. Click here to start watching.
Google today introduced Android KTX, a set of extensions to help developers write Kotlin code for Android that is “more concise, idiomatic, and pleasant.” The company promises to iterate on the API “over the next few months” based on developer contributions and feedback.
At its I/O 2017 developer conference in May, Google announced Android officially supports the Kotlin programming language, in addition to Java and C++. Android Studio 3.0 with Kotlin support followed in May.
Currently in preview, Android KTX provides an API layer on top of the Android framework and Support Library — the former is available now on GitHub. Google promises to make the other parts of Android KTX that cover the Android Support Library available in upcoming Support Library releases.
To start using Android KTX in your Android Kotlin projects, add the following to your app module’s build.gradle file:
// Android KTX for framework API
After you sync your project, the extensions will appear automatically in the IDE’s autocomplete list, and choosing any of them will add the necessary import statement to your file.
Google warns that the APIs are likely to change during the preview period. In other words, developers should not use it in their main Android projects, as there will be breaking changes before the stable version arrives. When the API has stabilized and Google commits to API compatibility, Android KTX will be released as part of the Android Support Library.
Android KTX uses package names that begin with androidx. Google also shared today that this is the new package name prefix for future versions of Android Support Library. The division between android.* and androidx.* is meant to help differentiate which APIs are bundled with the platform and which are static libraries for app developers that work across different versions of Android.
If you are interested in providing contributions and feedback on Android KTX, check out the “How to Contribute” section on GitHub.
VentureBeat's mission is to be a digital town square for technical decision-makers to gain knowledge about transformative enterprise technology and transact. Discover our Briefings.