Migrate to using the Kotlin extensions (KTX) APIs in the main modules

Firebase is increasing its commitment to Kotlin, and we're working to modernize our Android ecosystem to make Kotlin more accessible and easy-to-use with Firebase.

To accomplish this modernization, we're making a few changes to our Firebase SDKs for Android. This page describes important information about this change, including:


Learn how to migrate your app

What's changing?

The Kotlin extensions (KTX) APIs have been added to their respective main modules. For example, all the APIs from firebase-perf-ktx have been added to firebase-perf under the com.google.firebase.perf package.

This change means that Kotlin developers can now depend on the main modules instead of the KTX modules (when using Firebase BoM v32.5.0+ or main module versions listed in BoM v32.5.0+).

As part of this change, the Kotlin extensions (KTX) APIs in every KTX module are now deprecated. As early as April 2024, we'll no longer release KTX modules, and we'll also remove the KTX libraries from the Firebase Android BoM at that time.

Why are we making this change?

Firebase is committed to a Kotlin-first ecosystem for Android developers. This packaging modernization provides the following advantages:

  • Simplified dependency management: You now only need to depend on a single module, eliminating the need to switch between the main module and the Kotlin extensions or to depend on both.

  • Enhanced Kotlin support: All of our Firebase SDKs for Android will now provide better support for Kotlin. We'll include all the new Kotlin-friendly features directly in our main modules.

Important dates for this change

In October 2023

The Kotlin extensions (KTX) APIs were added to their respective main modules, which means that you can now use the KTX APIs directly from the main modules when using Firebase BoM v32.5.0+ or main module versions listed in BoM v32.5.0+.

In parallel, the Kotlin extension (KTX) APIs in the KTX modules were deprecated (see the release notes describing this change). During the deprecated phase, the deprecated APIs in the KTX modules will continue to function and be maintained.

As early as April 2024

We'll stop releasing new versions of the KTX modules, and we'll remove the KTX modules from the Firebase BoM.

Any previously released version of a KTX module or the BoM will continue to function, but they'll enter end-of-maintenance. This means that we'll stop adding bug fixes, backwards-compatible changes, and new features to the KTX modules. Instead, all future development for Firebase on Android will be done in the main modules (for both Java and Kotlin).

How to migrate to use KTX APIs from the main modules

If you use Kotlin extensions (KTX) APIs, make the following updates in your app to start using the APIs from the main modules instead of the KTX modules.

  1. Revise your Gradle dependencies to rely on the main module rather than the KTX module. For example, if you use the Firebase Android BoM (recommended):

    BEFORE

    dependencies {
      // ...
    
      // Import the Firebase BoM
      implementation(platform("com.google.firebase:firebase-bom:32.8.1"))
    
      // Using KTX libraries for Authentication and Cloud Firestore
      implementation("com.google.firebase:firebase-auth-ktx")
      implementation("com.google.firebase:firebase-firestore-ktx")
    }
    

    AFTER

    dependencies {
      // ...
    
      // Import the Firebase BoM as usual
      // Make sure to use Firebase BoM v32.5.0 or higher
      implementation(platform("com.google.firebase:firebase-bom:32.8.1"))
    
      // No need to use the KTX libraries, everything is now in the main module
      implementation("com.google.firebase:firebase-auth")
      implementation("com.google.firebase:firebase-firestore")
    }
    


  2. Update your code to replace all occurrences of the KTX APIs with the relocated APIs in the main module under the com.google.firebase package.

    BEFORE

    import com.google.firebase.auth.ktx.auth
    import com.google.firebase.firestore.ktx.firestore
    import com.google.firebase.firestore.ktx.toObject
    import com.google.firebase.ktx.Firebase
    

    AFTER

    import com.google.firebase.auth.auth
    import com.google.firebase.firestore.firestore
    import com.google.firebase.firestore.toObject
    import com.google.firebase.Firebase