Android KTX

Android KTX was a set of Kotlin extension modules for Android Jetpack libraries. Each module had a -ktx suffix, for example, androidx.core:core-ktx or androidx.fragment:fragment-ktx. These modules added extension functions, coroutine support, and other Kotlin features to the base libraries.

The AndroidX libraries are Kotlin-first, and the KTX extensions are moving into the base module of each library. For most libraries, the -ktx artifacts are empty starting in the versions in Libraries with a stable release, and you don't need them.

Remove KTX dependencies

To remove a KTX dependency for a library in Libraries with a stable release, follow these steps:

  1. Find the library in the Libraries with a stable release table.
  2. Make sure that your project uses the base artifact at the version in the table, or at a later version.
  3. Replace the -ktx artifact with the base artifact listed in the table. For example, replace androidx.fragment:fragment-ktx with androidx.fragment:fragment, and replace androidx.room:room-ktx with androidx.room:room-runtime.

You don't need to change your code or imports. The extensions keep the same package names.

Libraries with a stable release

For these libraries, the base artifact includes the extensions in a stable release. You can remove the -ktx dependency.

KTX artifact Base artifact Empty starting in version
androidx.activity:activity-ktxandroidx.activity:activity1.9.0
androidx.collection:collection-ktxandroidx.collection:collection1.3.0
androidx.core:core-ktxandroidx.core:core1.19.0
androidx.fragment:fragment-ktxandroidx.fragment:fragment1.9.0
androidx.lifecycle:lifecycle-livedata-ktxandroidx.lifecycle:lifecycle-livedata2.7.0
androidx.lifecycle:lifecycle-livedata-core-ktxandroidx.lifecycle:lifecycle-livedata-core2.8.0
androidx.lifecycle:lifecycle-reactivestreams-ktxandroidx.lifecycle:lifecycle-reactivestreams2.6.0
androidx.lifecycle:lifecycle-runtime-ktxandroidx.lifecycle:lifecycle-runtime2.8.0
androidx.lifecycle:lifecycle-viewmodel-ktxandroidx.lifecycle:lifecycle-viewmodel2.8.0
androidx.navigation:navigation-fragment-ktxandroidx.navigation:navigation-fragment2.4.0
androidx.navigation:navigation-runtime-ktxandroidx.navigation:navigation-runtime2.4.0
androidx.navigation:navigation-ui-ktxandroidx.navigation:navigation-ui2.4.0
androidx.paging:paging-common-ktxandroidx.paging:paging-common3.0.0
androidx.paging:paging-runtime-ktxandroidx.paging:paging-runtime3.0.0
androidx.paging:paging-rxjava2-ktxandroidx.paging:paging-rxjava23.0.0
androidx.palette:palette-ktxandroidx.palette:palette1.1.0
androidx.room:room-ktxandroidx.room:room-runtime2.7.0
androidx.savedstate:savedstate-ktxandroidx.savedstate:savedstate1.3.0
androidx.sqlite:sqlite-ktxandroidx.sqlite:sqlite2.7.0
androidx.tracing:tracing-ktxandroidx.tracing:tracing1.3.0
androidx.work:work-runtime-ktxandroidx.work:work-runtime2.9.0

Libraries without a stable release

For these libraries, the base artifact doesn't include the KTX extensions in a stable release. Keep the -ktx dependency until a stable release includes them.

KTX artifact Base artifact
androidx.concurrent:concurrent-futures-ktxandroidx.concurrent:concurrent-futures
androidx.dynamicanimation:dynamicanimation-ktxandroidx.dynamicanimation:dynamicanimation
androidx.preference:preference-ktxandroidx.preference:preference
androidx.transition:transition-ktxandroidx.transition:transition
androidx.wear.watchface:watchface-complications-data-source-ktxandroidx.wear.watchface:watchface-complications-data-source

Libraries that don't move to a base module

The androidx.appsearch:appsearch-ktx artifact is empty in all versions. You can remove it.

All public APIs in the androidx.security:security-crypto library are deprecated, together with its KTX module. The KTX extensions don't move to the base module. Remove the library from your project.