> ## Documentation Index
> Fetch the complete documentation index at: https://docs.permutive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migration Guide: v1.9.x to v1.10.x

> Upgrade from Permutive Android SDK v1.9.x to v1.10.x

This guide covers migrating from Permutive Android SDK v1.9.x to v1.10.x, which introduces contextual cohorts, Dagger dependency injection, and several improvements.

<Info>
  **Migration Difficulty:** Very Easy | **Estimated Time:** 15 minutes | **Breaking Changes:** None
</Info>

## What's New in v1.10.0

<CardGroup cols={2}>
  <Card title="Contextual Cohorts" icon="bullseye">
    Content-based segmentation for real-time targeting
  </Card>

  <Card title="Dagger Integration" icon="gear">
    Internal dependency injection framework (v2.53.1)
  </Card>

  <Card title="Google Ads 2.2.0" icon="google">
    Automatic contextual cohort targeting for GAM
  </Card>

  <Card title="AppNexus 1.7.0" icon="rectangle-ad">
    Automatic contextual cohort targeting for Xandr
  </Card>
</CardGroup>

<Check>
  **Good news:** This release is fully backward compatible with no breaking changes or deprecations.
</Check>

## Migration Steps

<Steps>
  <Step title="Update Dependencies">
    Update your `build.gradle.kts` or `build.gradle`:

    <Tabs>
      <Tab title="Before (v1.9.x)">
        ```kotlin theme={"dark"}
        dependencies {
            implementation("com.permutive.android:core:1.9.8")
            implementation("com.permutive.android:google-ads:2.1.0")
            implementation("com.permutive.android:appnexus:1.6.1")
        }
        ```
      </Tab>

      <Tab title="After (v1.10.0)">
        ```kotlin theme={"dark"}
        dependencies {
            implementation("com.permutive.android:core:1.10.0")
            implementation("com.permutive.android:google-ads:2.2.0")  // For GAM contextual
            implementation("com.permutive.android:appnexus:1.7.0")   // For Xandr contextual
        }
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Sync and Rebuild">
    ```bash theme={"dark"}
    ./gradlew clean build
    ```
  </Step>

  <Step title="Test Your Integration">
    Your existing code will continue to work without changes. Test to ensure:

    * Events are still being tracked
    * Cohorts are being received
    * Ad targeting is working
  </Step>
</Steps>

## Using New Features

### Contextual Cohorts

Contextual cohorts are automatically enabled if your workspace has the feature activated. No code changes required!

<AccordionGroup>
  <Accordion title="Accessing Contextual Cohorts" icon="code">
    ```kotlin theme={"dark"}
    val activations = permutive.currentActivations

    // Get Google Ad Manager contextual cohorts
    val gamContextual = activations["dfp_contextual"].orEmpty()

    // Get Xandr contextual cohorts
    val xandrContextual = activations["appnexus_adserver_contextual"].orEmpty()
    ```
  </Accordion>

  <Accordion title="Automatic Ad Integration" icon="rectangle-ad">
    If you're using our add-on libraries, contextual cohorts are automatically included:

    **Google Ad Manager:**

    ```kotlin theme={"dark"}
    // Contextual cohorts automatically added with key "prmtvctx"
    val adRequest = AdManagerAdRequest.Builder()
        .addPermutiveTargeting(permutive)
        .build()
    ```

    **Xandr/AppNexus:**

    ```kotlin theme={"dark"}
    // Contextual cohorts automatically added
    adView.addPermutiveTargeting(permutive)
    ```
  </Accordion>
</AccordionGroup>

See the [Contextual Data Guide](/sdks/mobile/android/core-concepts/contextual-data) for full documentation.

### Dagger Integration

v1.10.0 introduces Dagger for internal dependency management. This is an internal implementation detail.

<Note>
  **No action required.** Dagger is used internally by the SDK and doesn't require any changes to your code.
</Note>

<Accordion title="Resolving Dagger Conflicts">
  If your app also uses Dagger and you experience conflicts:

  1. Check your Dagger version matches or is compatible with v2.53.1
  2. Don't exclude Dagger from the Permutive SDK dependencies:

  ```kotlin theme={"dark"}
  // Don't do this:
  implementation("com.permutive.android:core:1.10.0") {
      exclude(group = "com.google.dagger")  // Will cause issues!
  }
  ```
</Accordion>

## Testing Your Migration

<AccordionGroup>
  <Accordion title="1. Verify Events" icon="check">
    Enable debug logging and verify events are still being tracked:

    ```kotlin theme={"dark"}
    permutive.setDeveloperMode(true)
    ```

    Look for:

    ```
    D/Permutive: Published events with names (Pageview) (Accepted: 1 / 1)
    ```
  </Accordion>

  <Accordion title="2. Check Cohorts" icon="users">
    Verify behavioral cohorts are still working:

    ```kotlin theme={"dark"}
    val cohorts = permutive.currentCohorts
    Log.d("Migration Test", "Cohorts: ${cohorts.size}")
    ```
  </Accordion>

  <Accordion title="3. Test Contextual (if enabled)" icon="bullseye">
    If contextual is enabled for your workspace:

    ```kotlin theme={"dark"}
    // Track a page with URL
    val pageTracker = permutive.trackPage(
        title = "Test Article",
        url = Uri.parse("https://example.com/test")
    )

    // Wait a moment for classification
    Handler(Looper.getMainLooper()).postDelayed({
        val contextual = permutive.currentActivations["dfp_contextual"]
        Log.d("Migration Test", "Contextual cohorts: $contextual")
    }, 2000)
    ```
  </Accordion>

  <Accordion title="4. Test Ad Integration" icon="rectangle-ad">
    Verify ads are still loading with targeting:

    ```kotlin theme={"dark"}
    val adRequest = AdManagerAdRequest.Builder()
        .addPermutiveTargeting(permutive)
        .build()

    adView.loadAd(adRequest)

    // Check logs for:
    // D/Permutive: Permutive segments appended to Google Ad request: ...
    ```
  </Accordion>
</AccordionGroup>

## Rollback

If you need to rollback to v1.9.x:

```kotlin theme={"dark"}
dependencies {
    implementation("com.permutive.android:core:1.9.8")
    implementation("com.permutive.android:google-ads:2.1.0")
    implementation("com.permutive.android:appnexus:1.6.1")
}
```

Then sync and rebuild.

## Requirements

v1.10.0 maintains the same minimum requirements as v1.9.x:

| Requirement | Version                |
| ----------- | ---------------------- |
| Android API | 21+ (Android 5.0)      |
| Compile SDK | 34+                    |
| Kotlin      | 1.6+ (if using Kotlin) |
| Java        | 8+ (JVM target 1.8)    |

## Getting Help

<CardGroup cols={2}>
  <Card title="Issues" icon="wrench" href="/sdks/mobile/android/troubleshooting/common-errors">
    Solutions to common issues
  </Card>

  <Card title="Contextual Data" icon="bullseye" href="/sdks/mobile/android/core-concepts/contextual-data">
    Full contextual documentation
  </Card>

  <Card title="Google Ad Manager" icon="google" href="/sdks/mobile/android/integrations/google-ad-manager">
    GAM integration guide
  </Card>

  <Card title="Cohorts & Activations" icon="users" href="/sdks/mobile/android/core-concepts/cohorts-and-activations">
    Understanding segments
  </Card>
</CardGroup>
