Develop
Develop
Select your platform

Set Up for Platform Development with Kotlin Android Apps

Updated: Jan 6, 2026
This guide will walk you through the basics of setting up your Android development environment and initializing the platform.

Prerequisites

Before you can integrate the Horizon Platform SDK for Android Kotlin, you’ll need to create an app, get the associated App ID, and use the App ID when configuring your development environment. To create an app, see the information on the Creating and Managing Apps page.

Get your App ID and package name

  1. In your browser, go to the Meta Horizon Developer Dashboard.
  2. From the left-side navigation, click My Apps.
  3. Choose your app from the list of apps.
  4. From the left-side navigation, click Development > API. You’ll find your App ID in the middle of the API page. You’ll need your App ID to call the initialization APIs described in the next few sections.
  5. From the left-side navigation, click Distribution > Builds.
  6. Open any build from the list of builds. You’ll find your Package Name in the middle of the Build Details page.

Create an Android project

  1. Open Android Studio
  2. Select File > New > New Project
  3. Select the “Empty Activity” template
  4. Click “Next”
  5. Fill the Project Settings
    • In Name, input a value such as “notification”
    • In Package Name, input the value from Prerequisites, such as “horizon.platform.sample.notification”
    • In Minimum SDK, select API 35 Android 15.0
    • In Build configuration language, select Kotlin DSL
  6. Click Finish
  7. Wait a few seconds until the project creation is completed
  8. In the top left, there is a dropdown menu with Android as current value, select Project so you can see all the files in the project

Use Kotlin 2.1

  1. Open the file ./gradle/libs.versions.toml
    • In the versions section, replace the version of the following libraries:
    [versions]
    // Find and Replace the version of the following libraries:
    activityCompose = "1.9.3"
    coreKtx = "1.13.1"
    kotlin = "2.1.0"
    
    • In the plugins section, add the compose compiler plugin
    [plugins]
    // Existing lines
    kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
    
  2. Open the file ./build.gradle.kts. In the plugins section, add the compose compiler plugin
    plugins {
        // Existing lines
        alias(libs.plugins.kotlin.compose) apply false
    }
    
  3. Open the file ./app/build.gradle.kts. In the plugins section, add the compose compiler plugin
    plugins {
        // Existing lines
        alias(libs.plugins.kotlin.compose)
    }
    
  4. In the menu bar, select File, Sync Project with Gradle Files
  5. In the menu bar, select Build, Generate App Bundles or APKs, Generate APKs

Import Horizon Platform SDK

Horizon Platform SDK for Android Kotlin is available in Maven Central. In this step, you will add the dependencies to your project.
  1. Open the file ./settings.gradle.kts. In the section dependencyResolutionManagement.repositories, add mavenCentral(). It should look similar to:
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
        }
    }
    
  2. Open the file ./gradle/libs.versions.toml
    • In the versions section, add the line below to set the SDK version
    [versions]
    // Existing lines
    horizonPlatformSdk = "0.2.0"
    
    • In the libraries section, add the SDK libraries
    [libraries]
    // Existing lines
    core-kotlin = { module = "com.meta.horizon.platform.sdk:core-kotlin", version.ref = "horizonPlatformSdk" }
    
  3. Open the file app/build.gradle.kts. In the dependencies section, add the SDK libraries. It should look similar to:
    dependencies {
        // Existing lines
        implementation(libs.core.kotlin)
    }
    
  4. In the menu bar, select File, Sync Project with Gradle Files
  5. In the menu bar, select Build, Generate App Bundles or APKs, Generate APKs
  6. In the left panel, expand the “External Libraries” section and you should see the SDK dependencies listed
    • com.meta.horizon.platform.sdk:core-kotlin

Initialize Horizon Platform SDK

The first step to integrating platform features is implementing the initialization function.
  1. Open the file MainActivity.kt
    • Add imports
    import android.content.Context
    import android.util.Log
    import horizon.core.android.driver.coroutines.HorizonServiceConnection
    import kotlinx.coroutines.coroutineScope
    import kotlinx.coroutines.runBlocking
    
    • Add this content and set the correct value in APPLICATION_ID
    fun onCreatePlatformSDK(context: Context) = runBlocking {
        initPlatformSDK(context)
    }
    
    suspend fun initPlatformSDK(context: Context) = coroutineScope {
        val TAG = "MainActivity"
        val APPLICATION_ID = "FILL_APP_ID"
        try {
            Log.i(TAG, "Connecting to Horizon Service with valid app id")
            HorizonServiceConnection.connect(APPLICATION_ID, context)
            Log.i(TAG, "PlatformSDK is ready!")
        } catch (e: Exception) {
            Log.e(TAG, "logging Exception", e)
        } catch (e: NoClassDefFoundError) {
            Log.e(TAG, "logging NoClassDefFoundError", e)
        }
    }
    
    • Find the line “override fun onCreate”, add this content to the bottom of the function body
    onCreatePlatformSDK(this@MainActivity.applicationContext)
    
    • Find the line “import horizon.core.android.driver.coroutines.HorizonServiceConnection”. You can hover over the class name “HorizonServiceConnection” and the package name “coroutines” to see the JavaDoc contents
  2. In the menu bar, select Build, Generate App Bundles or APKs, Generate APKs

Run the application

  1. Connect the headset to the computer using USB-C cable
  2. In the menu bar, select Build, Generate App Bundles or APKs, Generate APKs
  3. Open an Android Studio terminal
  4. Install the app
    adb install ./app/build/outputs/apk/debug/app-debug.apk
    
  5. Start the app
    APP_PACKAGE_NAME=horizon.platform.sample.notification
    adb shell am start-activity -n "$APP_PACKAGE_NAME/.MainActivity"
    
  6. Review logcat, you should see similar content
    14:21:51.972 MainActivity             I  Connecting to Horizon Service with valid app id
    14:21:51.998 HzServiceConnection      D  Horizon Platform connection: Start
    14:21:52.000 HzServiceConnection      D  Horizon Platform connection initialization state: horizon.core.android.driver.coroutines.HorizonServiceConnection$InitializationStage$Uninitialized@a71c274
    14:21:52.000 HzServiceConnection      D  Horizon Platform connection starting
    14:21:52.008 MainActivity             I  PlatformSDK is ready!
    14:21:52.047 HzServiceConnection      D  Horizon Platform connection created, getting global session id
    14:21:52.048 HzServiceConnection      D  Horizon Platform connection success!
    14:21:52.048 HzServiceConnection      D  Horizon Platform connection initialization state: horizon.core.android.driver.coroutines.HorizonServiceConnection$InitializationStage$Connected@3564b79
    
  7. Stop the app
    APP_PACKAGE_NAME=horizon.platform.sample.notification
    adb shell am force-stop "$APP_PACKAGE_NAME"
    
You completed project setup for using the Horizon Platform SDK and can start developing your app.

Horizon Platform SDK packages

For a complete list of packages, see Maven Central.
The following pages provide installation instructions for a selection of individual packages:
Did you find this page helpful?