Quickstart KMP (Android)

Team
SDK Team
Last Updated
May 29, 2026

Step 1 - Adding permissions to the Manifest

Add the following permissions in AndroidManifest.xml.

1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
4 <uses-permission android:name="android.permission.INTERNET" />
5 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
6 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
7 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
8 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
9 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
10 <uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
11 <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
12 <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
13 <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
14
15 ...
16
17</manifest>

Step 2 - Installing the Group Link library

  1. In the settings.gradle.kts file, add the Jitpack URL inside the repositories section:
1...
2
3dependencyResolutionManagement {
4 repositories {
5 google {
6 ...
7 }
8 mavenCentral()
9 maven { url = uri("https://jitpack.io") } // Package repository for Android libraries.
10 }
11}
12
13...
  1. In your project's build.gradle(androidApp), add the Group Link library by adding the following implementation:
1...
2
3dependencies {
4 ...
5 implementation("com.grouplinknetwork:lib-grouplinknetwork:4+") // Implementation of the Android library from the Group Link SDK
6}
7
8...

Step 3 - Creating the JSON file with your Group Link Token

  1. Create a file named grouplink-services.json inside the directory .../androidApp/src/main/assets/.
Note: Create the directory .../androidApp/src/main/assets/ if it doesn't already exist in your project.
Estrutura de pastas de um app Android no Android Studio. O diretório androidApp/src/main/assets está expandido, com o arquivo grouplink-services.json selecionado e destacado.
  1. Insert the following content below into the JSON
Note: Replace the YOUR_GROUP_LINK_TOKEN with your authentication token (provided by Group Link).
1{
2 "token": "YOUR_GROUP_LINK_TOKEN"
3}

Step 4 - Requesting permissions at runtime

In your project, search for your MainActivity and add the permissions following the model below.

  1. Import the Group Link library.
  2. Request permissions at runtime.
1// Example of permission request for Android
2
3package com.grouplink.kmp.test.androidApp
4
5import android.Manifest
6import android.app.Activity
7...
8import com.grouplinknetwork.GroupLink // <---- Importing the Group Link library
9
10
11class MainActivity : ComponentActivity() {
12 private val REQUEST_PERMISSION_CODE = 420 // Request code for necessary permissions
13 private val ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE = 0 // Request code for necessary permissions (Android 6)
14 private var count = 0 // Counter to prevent repeated permission requests
15 private var countAutoStart = 0 // Counter to prevent repeated auto-start permission requests
16
17 // Counter to prevent repeated auto-start permission requests
18 private val REQUIRED_PERMISSIONS = arrayOf(
19 Manifest.permission.BLUETOOTH,
20 Manifest.permission.BLUETOOTH_ADMIN,
21 Manifest.permission.ACCESS_FINE_LOCATION,
22 Manifest.permission.ACCESS_COARSE_LOCATION
23 )
24
25 // Permissions required for operation on Android 10 (Q)
26 private val REQUIRED_PERMISSIONS_Q = arrayOf(
27 Manifest.permission.BLUETOOTH,
28 Manifest.permission.BLUETOOTH_ADMIN,
29 Manifest.permission.ACCESS_FINE_LOCATION,
30 Manifest.permission.ACCESS_COARSE_LOCATION
31 )
32
33 // Logic for operation on Android 12 (S) and 13 (Tiramisu)
34 private fun getRequiredPermissionsS(): Array<String> {
35 return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
36 arrayOf(
37 Manifest.permission.BLUETOOTH,
38 Manifest.permission.BLUETOOTH_ADMIN,
39 Manifest.permission.ACCESS_FINE_LOCATION,
40 Manifest.permission.ACCESS_COARSE_LOCATION,
41 Manifest.permission.BLUETOOTH_SCAN,
42 Manifest.permission.BLUETOOTH_ADVERTISE,
43 Manifest.permission.BLUETOOTH_CONNECT,
44 Manifest.permission.POST_NOTIFICATIONS
45 )
46 } else {
47 arrayOf(
48 Manifest.permission.BLUETOOTH,
49 Manifest.permission.BLUETOOTH_ADMIN,
50 Manifest.permission.ACCESS_FINE_LOCATION,
51 Manifest.permission.ACCESS_COARSE_LOCATION,
52 Manifest.permission.BLUETOOTH_SCAN,
53 Manifest.permission.BLUETOOTH_ADVERTISE,
54 Manifest.permission.BLUETOOTH_CONNECT
55 )
56 }
57 }
58
59 // The onCreate method is where the Group Link SDK is registered and permissions are requested
60 override fun onCreate(savedInstanceState: Bundle?) {
61 super.onCreate(savedInstanceState)
62 enableEdgeToEdge()
63
64 // Starting the Group Link SDK
65 GroupLink.register(
66 this, // Application context
67 false // Parameter to enable or disable debug mode
68 )
69
70 requestGlPermissions() // Requesting the necessary permissions for the Group Link SDK to function.
71
72 ...
73 }
74
75 // Method for requesting the necessary permissions
76 private fun requestGlPermissions() {
77 // Requesting permissions for Android 12 (S)
78 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
79 if (!hasNeededPermissionsS()) {
80 requestPermissionsS()
81 return
82 }
83 }
84
85 // Requesting permissions for Android 10 (Q)
86 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
87 if (!hasNeededPermissionsQ()) {
88 requestPermissionsQ()
89 return
90 }
91 }
92
93 // Requesting permissions up to Android 9 (Pie)
94 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
95 if (!hasNeededPermissions()) {
96 requestPermissions()
97 return
98 }
99 }
100
101 // Checking if all permissions have already been granted
102 if (countAutoStart < 1) {
103 countAutoStart++
104 }
105 }
106
107 // Method to verify if the necessary permissions have been granted
108 private fun hasNeededPermissions(): Boolean {
109 return REQUIRED_PERMISSIONS.all {
110 ActivityCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
111 }
112 }
113
114 // Method to check if the necessary permissions have been granted for Android 10 (Q)
115 private fun hasNeededPermissionsQ(): Boolean {
116 return REQUIRED_PERMISSIONS_Q.all {
117 ActivityCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
118 }
119 }
120
121 // Method to check if the necessary permissions have been granted for Android 12 (S)
122 private fun hasNeededPermissionsS(): Boolean {
123 return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
124 getRequiredPermissionsS().all {
125 ActivityCompat.checkSelfPermission(this, it) == PackageManager.PERMISSION_GRANTED
126 }
127 } else true
128 }
129
130 // Methods for requesting the necessary permissions for the Group Link SDK to function.
131 private fun requestPermissions() {
132 ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS, REQUEST_PERMISSION_CODE)
133 }
134
135 // Method to request the necessary permissions for Android 10 (Q)
136 private fun requestPermissionsQ() {
137 ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS_Q, REQUEST_PERMISSION_CODE)
138 }
139
140 // Method for requesting the necessary permissions for Android 12 (S)
141 private fun requestPermissionsS() {
142 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
143 ActivityCompat.requestPermissions(this, getRequiredPermissionsS(), REQUEST_PERMISSION_CODE)
144 }
145 }
146
147 // Method for handling the results of permission requests.
148 override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
149 if (requestCode == REQUEST_PERMISSION_CODE) {
150 if (count < REQUIRED_PERMISSIONS_Q.size) {
151 count++
152 requestGlPermissions()
153 return
154 }
155
156 if (countAutoStart < 1) {
157 countAutoStart++
158 }
159 }
160
161 super.onRequestPermissionsResult(requestCode, permissions, grantResults)
162 }
163}
164
165...
166

Now that the Group Link SDK for Android is implemented and the native features are configured, your KMP application is ready to interact with our ecosystem!