Firebase Kotlin Extensions are out of Beta!

Firebase banner. Illustration of a laptop screen and KXT extension
Firebase banner. Illustration of a laptop screen and KXT extension

We know that Kotlin is the future of Android and that Kotlin developers want clean, idiomatic APIs when they use Firebase in their apps. For the past year, we’ve been releasing Firebase Kotlin extension (KTX) libraries alongside our Android Java SDKs to give Kotlin developers the best of both worlds.

Today, we’re happy to announce that these KTX libraries are out of Beta and recommended for all Firebase developers using Kotlin in their Android apps!

So what does this mean for you?

To get started with our KTX libraries, look for the -ktx suffix in the “Kotlin+KTX” section of our available Android libraries. As an example, let’s see what it looks like to set up Remote Config with and without the KTX library.

app/build.gradle (before)

implementation 'com.google.firebase:firebase-config:19.1.2' 

MainActivity.kt (before)

val remoteConfig = FirebaseRemoteConfig.getInstance()

val configSettings = FirebaseRemoteConfigSettings.Builder()
        .setMinimumFetchIntervalInSeconds(3600)
        .setFetchTimeoutInSeconds(60)
        .build()
remoteConfig.setConfigSettingsAsync(configSettings) 

app/build.gradle (after)

// The -ktx library has a dependency on the firebase-config library
implementation 'com.google.firebase:firebase-config-ktx:19.1.2' 

MainActivity.kt (after)

// New global "Firebase" class
val remoteConfig = Firebase.remoteConfig

// New settings builder syntax
val configSettings = remoteConfigSettings {
    minimumFetchIntervalInSeconds = 3600
    fetchTimeoutInSeconds = 60
}
remoteConfig.setConfigSettingsAsync(configSettings) 

And the KTX libraries that we have available today are just the beginning, as we’re working hard to add coverage for all Firebase products and add new Kotlin-focused features in the near future!

We wouldn’t have been able to release these KTX libraries without the help of all the Kotlin enthusiasts in the Firebase community. We’d like to give a special shout out to Rosário Pereira Fernandes who contributed so much excellent code and documentation to the KTX effort.

If you have feedback or want to contribute, you can find us on GitHub.