Install Nativebrik SDK to your Android project
System requirements:
- minimum Android API level: 26 or higher
- minimum Kotlin version: 1.9.10 or higher
Step 1. Install Nativebrik SDK to your app
Nativebrik SDK is available through Maven Central. Therefore, you can install it by several ways:
Gradle
Add the following to your build.gradle
file:
build.gradle
dependencies {
implementation 'com.nativebrik:sdk:0.0.6'
}
or if you are using Kotlin DSL:
build.gradle.kts
dependencies {
implementation("com.nativebrik:sdk:0.0.6")
}
Apache Maven
Add the following to your pom.xml
file:
pom.xml
<dependency>
<groupId>com.nativebrik</groupId>
<artifactId>sdk</artifactId>
<version>0.0.6</version>
<type>pom</type>
</dependency>
Step 2. Initialize Nativebrik SDK in your composable app.
MainActivity.kt
// Import Nativebrik SDK
import com.nativebrik.sdk.Config
import com.nativebrik.sdk.Nativebrik
import com.nativebrik.sdk.NativebrikClient
import com.nativebrik.sdk.NativebrikProvider
class MainActivity : ComponentActivity() {
private lateinit var nativebrik: NativebrikClient
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize Nativebrik SDK to pass it to NativebrikProvider
this.nativebrik = NativebrikClient(
config = Config(projectId = "<YOUR_NATIVEBRIK_PROJECT_ID>"),
context = this.applicationContext,
)
setContent {
YourAndroidTheme {
// declare Nativebrik Provider to the root of your app.
NativebrikProvider(client = nativebrik) {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
// Your composable app
}
}
}
}
}
override fun onDestroy() {
// Close Nativebrik SDK when the app is destroyed not to leak resources.
this.nativebrik.close()
super.onDestroy()
}
}