Add Android SDK to your app
Add Android SDK to your app
1. Add the SDK
Using Gradle Kotlin DSL (build.gradle.kts)
build.gradle.kts)Add the following dependencies to your app-level build.gradle.kts:
implementation("im.arena:comment-system-android:1.0.1-alpha03")
implementation("im.arena:common-android:1.0.1-alpha03")
implementation("im.arena:auth:1.0.1-alpha03")Check the latest available versions at:
- https://central.sonatype.com/artifact/im.arena/comment-system-android
- https://central.sonatype.com/artifact/im.arena/common-android
- https://central.sonatype.com/artifact/im.arena/auth
After adding the dependencies, sync your project.
2. Configure ProGuard
If you build your APK with minifyEnabled true, add the following rule to your proguard-rules.pro file:
-keep class im.arena.commentsystem.** { *; }3. Setup SDK
Required imports in your Activity
import im.arena.auth.AuthManager
import im.arena.commentsystem.ArenaCommentSystem
import im.arena.commentsystem.Environment
import im.arena.common.ContextFactoryDefine constants
Inside your Activity:
companion object {
private const val SITE_ID_COMMENT_SYSTEM = "YOUR_SITE_ID"
private const val NAME = "Any Name"
private const val THREAD_ID = "YOUR_THREAD_ID"
private const val GOOGLE_CLIENT_ID = "YOUR_GOOGLE_CLIENT_ID"
private const val URL = "YOUR_PAGE_URL"
private const val PAGE_TITLE = "Your comment system Page Title"
private const val THREAD_PROFILE_ID = "YOUR_THREAD_PROFILE_ID"
}You can retrieve:
- SITE_ID
- THREAD_ID
- THREAD_PROFILE_ID
- URL
- PAGE_TITLE
from the Arena Dashboard or via the Platform API.
Initialize authentication
Call this in your Activity (recommended inside onCreate()):
AuthManager.initialize(
this,
GOOGLE_CLIENT_ID
)4. Add the Comment System to your layout
Place the ArenaCommentSystem composable wherever you want the comments UI to appear:
ArenaCommentSystem(
ContextFactory(this@MainActivity),
SITE_ID_COMMENT_SYSTEM,
URL,
NAME,
PAGE_TITLE,
THREAD_ID,
THREAD_PROFILE_ID
)5. Full Activity Example
Below is a complete working example of an Android Activity using Jetpack Compose and the Arena Comment System SDK.
All sensitive keys are intentionally hidden.
package com.example.arenacomments
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import im.arena.auth.AuthManager
import im.arena.commentsystem.ArenaCommentSystem
import im.arena.commentsystem.Environment
import im.arena.common.ContextFactory
class MainActivity : ComponentActivity() {
companion object {
private const val SITE_ID_COMMENT_SYSTEM = "YOUR_SITE_ID"
private const val NAME = "Test"
private const val THREAD_ID = "YOUR_THREAD_ID"
private const val GOOGLE_CLIENT_ID = "YOUR_GOOGLE_CLIENT_ID"
private const val URL = "YOUR_PAGE_URL"
private const val PAGE_TITLE = "Your Page Title"
private const val THREAD_PROFILE_ID = "YOUR_THREAD_PROFILE_ID"
}
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContent {
AuthManager.initialize(
this,
GOOGLE_CLIENT_ID
)
MaterialTheme {
Scaffold(
modifier = Modifier.fillMaxSize()
) { contentWindowInsets ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(
top = contentWindowInsets.calculateTopPadding(),
bottom = contentWindowInsets.calculateBottomPadding()
)
.consumeWindowInsets(contentWindowInsets),
contentAlignment = Alignment.Center
) {
ArenaCommentSystem(
ContextFactory(this@MainActivity),
SITE_ID_COMMENT_SYSTEM,
URL,
NAME,
PAGE_TITLE,
THREAD_ID,
THREAD_PROFILE_ID,
Environment.DEVELOPMENT
)
}
}
}
}
}
}6. Notes
- The Comment System is built using Jetpack Compose, allowing full UI customization and flexible screen embedding.
- Initialization should occur once per Activity lifecycle.
Updated 1 day ago