Create your own Realtime Analytics App using Firestore in Android

dependencies {
// Import the BoM for the Firebase platform
implementation platform('')

// Declare the dependency for the Cloud Firestore library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation ''
fun trackEvent(screenName: String, eventName: String) {
.update(eventName, FieldValue.increment(1))
override fun onCreate(savedInstanceState: Bundle?) {

Common.trackEvent("Screens", "MainScreen")
.addSnapshotListener { snapshot, e ->
if (snapshot != null && snapshot.exists()) {
tvMainScreen.text =!! ["MainScreen"].toString()
} else {
tvMainScreen.text = null




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store