Google announced Kotlin as first class citizen on Android in Google I/O 2017 and Jetpack set of libraries in Google I/O 2018. Since then they've made great progress in providing support for Kotlin and Jetpack for application developers.
With the release of Android Pie (9.0.0) the support for Kotlin and Jetpack has extended to system applications. It is, though, still work in progress.
The support for Kotlin and support libraries was tentatively present on the platform since their introduction and full support for 3rd party developers including tools and documentation was there from day one, however in order to make everything work with the platform build, additional work was required by the developer and in some cases things were simply missing.
Now, Soong build tool provides support for Kotlin and most Jetpack libraries. To add Kotlin support all you have to do is list .kt files in 'srcs' element of your .bp file and for Jetpack add appropriate library to a library section, e.g. 'static_libs'.
The build support is available for Soong only. Make is not supported.
Naming of libraries in .bp files DOES NOT fully comply to the usual Maven nomenclature you would use in a gradle file e.g. in Android Studio. The difference is that Soong uses '_' as separator instead of ':' and also version is not stated in the blueprint file - you will always get the latest platform build of the support library, e.g.
androidx.core:core:1.0.0-rc01 -> androidx.core_core
As of this writing the version of kotlin used in AOSP is 1.3.0.
- As of this writing the version of Androidx libraries is 1.0.0-alpha1, however with build you will always get the latest version available so bear that in mind when syncing your repo and building the application.
- Unfortunately, not all Jetpack libraries are supported out of box, only those that are part of sdk build. Notably, Kotlin extensions are missing.
(...as of this writing, see date in the commit.)
Soong invokes kotlinc for compilation, so it is useful to be able to add certain flags, e.g. -Werror, -P plugin... etc., and this is now supported out of box thanks to the following patch in AOSP: https://android-review.googlesource.com/c/platform/build/soong/+/735669 See Android.bp file for usage.
Note that the following flags are not allowed: -no-sdk, -no-jdk (they are already set by default), -kotlin-home and -Xintellij-plugin-root (default kotlin home is used for consistency of platform builds).
- Kotlinc plugins should be supported via kotlinc flags.
- Kotlin extensions libraries from Jetpack are not supported, as they are not part of the sdk build of Jetpack.
The project is licensed under the license stated in the LICENCE.md file of this project.
As much as I'm surprised that you would want to contribute to this small project, you are more than welcome to do so by submitting issues and PRs or sending patch files. Thanks!