Develop
Develop
Select your platform

Set Up for Platform Development with Kotlin Android Apps

Updated: Sep 20, 2025
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 from the Developer Dashboard
  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.

Create 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 notification
    • In Package Name, input 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.1.2"
    
    • In the libraries section, add the SDK libraries
     [libraries]
     // Existing lines
     push-notification-kotlin = { module = "com.meta.horizon.platform.sdk:push-notification-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.push.notification.kotlin)
         implementation("com.facebook.kotlin.compilerplugins.dataclassgenerate:superclass-jvm:1.0.1")
     }
    
  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
    • com.meta.horizon.platform.sdk:push-notification-kotlin

Initialize Horizon Platform SDK

The first step to integrating platform features is implementing the initialization function.
  1. Open the file MainActivity.kt
    • 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)
             val pushNotification = PushNotification()
             val result: PushNotificationResult = pushNotification.register()
             Log.d(TAG, result.json)
             Log.i(TAG, "PlatformSDK is ready!")
         } catch (e: Exception) {
             Log.e(TAG, "logging Exception", e)
         } catch (e: NoClassDefFoundError) {
             Log.e(TAG, "logging NoClassDefFoundError", e)
         }
     }
    
    • Resolve the import errors
    • Find the line “import horizon.platform.pushnotification.PushNotification”. You can hover over the class name “PushNotification” and the package name “pushnotification” to see the JavaDoc contents
    • Find the line “override fun onCreate”, add this content to the bottom of the function body
     onCreatePlatformSDK(this@MainActivity.applicationContext)
    
  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
     10:59:34.226 MainActivity             I  Connecting to Horizon Service with valid app id
     10:59:34.259 HzServiceConnection      D  Horizon Platform connection: Start
     10:59:34.260 HzServiceConnection      D  Horizon Platform connection initialization state: horizon.core.android.driver.coroutines.HorizonServiceConnection$InitializationStage$Uninitialized@4c8834d
     10:59:34.260 HzServiceConnection      D  Horizon Platform connection starting
     10:59:34.289 HzServiceConnection      D  Horizon Platform connection created, getting global session id
     10:59:34.291 HzServiceConnection      D  Horizon Platform connection success!
     10:59:34.291 HzServiceConnection      D  Horizon Platform connection initialization state: horizon.core.android.driver.coroutines.HorizonServiceConnection$InitializationStage$Connected@9d04313
     10:59:36.690 MainActivity             D  {"id":"750266551340136"}
     10:59:36.691 MainActivity             I  PlatformSDK is ready!
    
  7. Stop the app
     APP_PACKAGE_NAME=horizon.platform.sample.notification
     adb shell am force-stop "$APP_PACKAGE_NAME"
    
That’s it! You can now start developing an application using the Horizon Platform SDK.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon