> For the complete documentation index, see [llms.txt](https://docs.nubrick.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nubrick.app/start/install/android.md).

# Android

## サポート環境

* Android minSdk 26 以上
* Android Gradle Plugin 8.0 以上

***

## Step 1. パッケージをインストールする

Nubrick SDK は Maven Central から追加できます。

* [Maven Central](https://central.sonatype.com/artifact/app.nubrick/nubrick)

{% tabs %}
{% tab title="Gradle (Groovy)" %}
`build.gradle` に以下を追加します。

```gradle
dependencies {
  implementation 'app.nubrick:nubrick:<LATEST_VERSION>'
}
```

{% endtab %}

{% tab title="Gradle (Kotlin DSL)" %}
`build.gradle.kts` に以下を追加します。

```kotlin
dependencies {
  implementation("app.nubrick:nubrick:<LATEST_VERSION>")
}
```

{% endtab %}

{% tab title="Apache Maven" %}
`pom.xml` に以下を追加します。

```xml
<dependency>
  <groupId>app.nubrick</groupId>
  <artifactId>nubrick</artifactId>
  <version>${LATEST_VERSION}</version>
</dependency>
```

{% endtab %}
{% endtabs %}

## Step 2. Nubrick SDK を初期化する

{% hint style="warning" %}
`NubrickSDK.initialize(...)` は、`Embedding` / `RemoteConfig` / `dispatch` など他の API を使う前に、必ず 1 回だけ実行してください。
{% endhint %}

### Jetpack Compose

アプリ全体で 1 回だけ初期化するため、`Application` の `onCreate` で SDK を初期化し、`Activity` 側ではルート Composable を `NubrickProvider { ... }` で包みます。

```kotlin
import android.app.Application
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import app.nubrick.nubrick.Config
import app.nubrick.nubrick.NubrickProvider
import app.nubrick.nubrick.NubrickSDK

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        NubrickSDK.initialize(
            context = this,
            config = Config(projectId = "<YOUR_NUBRICK_PROJECT_ID>")
        )
    }
}

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            NubrickProvider {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    NubrickSDK.Embedding(
                        id = "ID_OF_YOUR_EMBEDDING",
                        modifier = Modifier.height(240.dp)
                    )
                }
            }
        }
    }
}
```

既存の `Application` クラスがある場合は、その `onCreate` で `NubrickSDK.initialize(...)` を実行してください。\
`Application` クラスがない場合、新規作成して `AndroidManifest.xml` の `android:name` に指定してください。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nubrick.app/start/install/android.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
