Join gaming leaders, alongside GamesBeat and Facebook Gaming, for their 2nd Annual GamesBeat & Facebook Gaming Summit | GamesBeat: Into the Metaverse 2 this upcoming January 25-27, 2022. Learn more about the event.
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.
VentureBeatVentureBeat's mission is to be a digital town square for technical decision-makers to gain knowledge about transformative technology and transact. Our site delivers essential information on data technologies and strategies to guide you as you lead your organizations. We invite you to become a member of our community, to access:
- up-to-date information on the subjects of interest to you
- our newsletters
- gated thought-leader content and discounted access to our prized events, such as Transform 2021: Learn More
- networking features, and more