# Android API移行ガイド（旧→新）

このページは、旧 Android API（`NubrickClient` 系）から現行 API（`NubrickSDK` 系）への移行ポイントをまとめたものです。

## 対応表

| 旧API                                    | 新API                                           |
| --------------------------------------- | ---------------------------------------------- |
| `NubrickClient(config, context)`        | `NubrickSDK.initialize(context, config)`       |
| `nubrick.experiment.dispatch(...)`      | `NubrickSDK.dispatch(...)`                     |
| `nubrick.experiment.Embedding(...)`     | `NubrickSDK.Embedding(...)`                    |
| `nubrick.experiment.RemoteConfig(...)`  | `NubrickSDK.RemoteConfig(...)`                 |
| `nubrick.experiment.remoteConfig(...)`  | `NubrickSDK.remoteConfig(...)`                 |
| `nubrick.user.setProperties(...)`       | `NubrickSDK.setUserProperties(...)`            |
| `nubrick.user.setProperty(...)`         | `NubrickSDK.setUserProperty(...)`              |
| `nubrick.user.getProperty(...)`         | `NubrickSDK.getUserProperty(...)`              |
| `nubrick.user.userId / getProperties()` | `NubrickSDK.getUserId() / getUserProperties()` |
| `NubrickProvider(client = ...)`         | `NubrickProvider { ... }`                      |
| `nubrick.close()`                       | （不要）                                           |

## 主要な書き換え例

### 1) 初期化

```kotlin
// Before
val nubrick = NubrickClient(
    config = Config(projectId = "<PROJECT_ID>"),
    context = applicationContext,
)

// After
NubrickSDK.initialize(
    context = applicationContext,
    config = Config(projectId = "<PROJECT_ID>"),
)
```

### 2) 埋め込み（Compose）

```kotlin
// Before
nubrick.experiment.Embedding("TOP_COMPONENT")

// After
NubrickSDK.Embedding("TOP_COMPONENT")
```

### 3) ユーザープロパティ

```kotlin
// Before
nubrick.user.setProperties(mapOf("plan" to "gold"))

// After
NubrickSDK.setUserProperties(mapOf("plan" to "gold"))
```

### 4) Provider

```kotlin
// Before
NubrickProvider(client = nubrick) {
    AppContent()
}

// After
NubrickProvider {
    AppContent()
}
```

## 注意点

* 旧 `NubrickClient` / `NubrickExperiment` を前提としたコードはそのままでは動きません。
* `NubrickSDK.initialize(...)` は、他の API を呼ぶ前に 1 回だけ実行してください。
* Compose でオーバーレイ配信を表示する場合は、`NubrickProvider` でルートを包んでください。


---

# Agent Instructions: 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:

```
GET https://docs.nubrick.app/guide/android-api-migration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
