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.
The first step to integrating platform features is implementing the initialization function.
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
APP_PACKAGE_NAME=horizon.platform.sample.notification
adb shell am start-activity -n "$APP_PACKAGE_NAME/.MainActivity"
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!
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.