Skip to main content

Android Quickstart

From zero to your first event in about five minutes, for Android apps (Kotlin or Java).

1. Get an API key​

Sign up at app.mostlygoodmetrics.com and create a project. Copy the API key from the project's settings — it looks like mgm_proj_xxxx.

2. Install​

Use 0.7.1 or later for the SDK safety fixes; see the Android SDK guide for failure handling.

Add the JitPack repository to your settings.gradle.kts:

dependencyResolutionManagement {
repositories {
maven { url = uri("https://jitpack.io") }
}
}

Then add the dependency:

dependencies {
implementation("com.github.Mostly-Good-Metrics:mostly-good-metrics-android-sdk:0.7.1")
}

Requires Android SDK 21+ (Android 5.0) and Kotlin 1.9+.

3. Initialize​

Configure the SDK once in your Application class:

import com.mostlygoodmetrics.sdk.MostlyGoodMetrics

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
MostlyGoodMetrics.configure(this, "mgm_proj_your_api_key")
}
}

4. Track your first event​

MostlyGoodMetrics.track("first_event", mapOf(
"source" to "quickstart"
))

Events are persisted locally, batched, and flushed automatically (every 30 seconds and when the app backgrounds). The SDK also tracks $app_installed and $app_opened for you on launch.

5. Verify in the dashboard​

Open your project at app.mostlygoodmetrics.com — first_event (and the automatic $app_opened) should appear within a few seconds of the SDK flushing. Backgrounding the app forces a flush.

If nothing shows up:

  • Enable debug logging via MGMConfiguration.Builder("...").enableDebugLogging(true) and watch logcat
  • Check that the API key matches the project you're looking at

Next steps​