> ## 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.

# Android SDK

> Integrate Permutive into your Android application for user segmentation, personalization, and ad targeting

export const SDKKeyConcepts = () => <AccordionGroup>
    <Accordion title="Cohorts vs. Activations">
      - **Cohorts**: All segments a user belongs to
      - **Activations**: Cohorts configured for specific ad platforms
    </Accordion>

    <Accordion title="Behavioral vs. Contextual">
      - **Behavioral**: Based on user history (e.g., "sports enthusiast")
      - **Contextual**: Based on current content (e.g., viewing sports article right now)
    </Accordion>

    <Accordion title="Identity Resolution">
      Multiple identifiers (email, user ID, ad ID) linked to single user profile for cross-device tracking.
    </Accordion>
  </AccordionGroup>;

<CardGroup cols={4}>
  <Card title="Quick Start" href="/sdks/mobile/android/getting-started/quick-start" icon="rocket" />

  <Card title="Features" href="#features" icon="puzzle-piece" />

  <Card title="Integrations" href="#integrations" icon="plug" />

  <Card title="Issues" href="/sdks/mobile/android/troubleshooting/common-errors" icon="triangle-exclamation" />
</CardGroup>

## Overview

The Permutive Android SDK enables user segmentation, personalization, and ad targeting in your Android application. Track user behavior, manage identities across devices, and deliver targeted advertising through integrations with major ad platforms.

## Getting Started

New to the Permutive Android SDK? Start here.

<CardGroup cols={2}>
  <Card title="Quick Start Guide" icon="rocket" href="/sdks/mobile/android/getting-started/quick-start">
    Get up and running with your first page view in minutes
  </Card>

  <Card title="Installation" icon="download" href="/sdks/mobile/android/getting-started/installation">
    Detailed installation and dependency setup
  </Card>

  <Card title="Initialization" icon="gear" href="/sdks/mobile/android/getting-started/initialization">
    SDK initialization patterns and configuration
  </Card>

  <Card title="Verification" icon="circle-check" href="/sdks/mobile/android/getting-started/verification">
    Verify your integration is working correctly
  </Card>
</CardGroup>

## Core Concepts

Understand the fundamental concepts of the Permutive SDK.

<CardGroup cols={2}>
  <Card title="Identity Management" icon="user" href="/sdks/mobile/android/core-concepts/identity-management">
    Track users across devices and sessions
  </Card>

  <Card title="Event Properties" icon="list" href="/sdks/mobile/android/core-concepts/event-properties">
    Structure and validate event data
  </Card>

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

  <Card title="Contextual Data" icon="bullseye" href="/sdks/mobile/android/core-concepts/contextual-data">
    Content-based real-time targeting
  </Card>
</CardGroup>

## Features

Detailed guides for specific SDK features.

<CardGroup cols={2}>
  <Card title="Page Tracking" icon="file" href="/sdks/mobile/android/features/page-tracking">
    Track pageviews and user engagement (recommended approach)
  </Card>

  <Card title="Event Tracking" icon="bolt" href="/sdks/mobile/android/features/event-tracking">
    Track custom events
  </Card>

  <Card title="Video Tracking" icon="video" href="/sdks/mobile/android/features/video-tracking">
    Track video content viewing
  </Card>

  <Card title="Video Ad Tracking" icon="rectangle-ad" href="/sdks/mobile/android/features/video-ad-tracking">
    Track video advertisement engagement
  </Card>

  <Card title="Triggers Provider" icon="bell" href="/sdks/mobile/android/features/triggers-provider">
    React to cohort changes in real-time
  </Card>
</CardGroup>

## Integrations

Connect Permutive with ad platforms and other services.

<CardGroup cols={2}>
  <Card title="View All Integrations" icon="plug" href="/sdks/mobile/android/integrations/overview">
    Google Ad Manager, Xandr, and more
  </Card>

  <Card title="AAID Provider" icon="fingerprint" href="/sdks/mobile/android/integrations/aaid-provider">
    Automatic advertising ID tracking
  </Card>
</CardGroup>

## Common Tasks

<AccordionGroup>
  <Accordion title="Track a Page View (Recommended)" icon="file">
    **PageTracker is the recommended approach** for tracking user interactions as it integrates with Permutive's standard events and provides richer insights.

    ```kotlin theme={"dark"}
    class ArticleActivity : AppCompatActivity() {

        private lateinit var pageTracker: PageTracker

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

            pageTracker = permutive.trackPage(
                title = "Article Title",
                url = Uri.parse("https://example.com/article"),
                eventProperties = EventProperties.from(
                    "category" to "sports",
                    "author" to "John Doe"
                )
            )
        }

        override fun onPause() {
            super.onPause()
            pageTracker.pause()
        }

        override fun onResume() {
            super.onResume()
            pageTracker.resume()
        }

        override fun onDestroy() {
            super.onDestroy()
            pageTracker.close()
        }
    }
    ```
  </Accordion>

  <Accordion title="Set User Identity" icon="user">
    ```kotlin theme={"dark"}
    val emailHash = hashEmail(userEmail)
    permutive.setIdentity(
        listOf(
            Alias.create("email_sha256", emailHash, priority = 0),
            Alias.create("internal_id", userId, priority = 1)
        )
    )
    ```
  </Accordion>

  <Accordion title="React to Cohort Changes" icon="bell">
    ```kotlin theme={"dark"}
    val trigger = triggersProvider.triggerAction("premium_user") { isInCohort ->
        if (isInCohort) {
            showPremiumFeatures()
        }
    }

    // Don't forget to close!
    override fun onDestroy() {
        super.onDestroy()
        trigger.close()
    }
    ```
  </Accordion>

  <Accordion title="Target Google Ads" icon="bullseye">
    ```kotlin theme={"dark"}
    val adRequest = AdManagerAdRequest.Builder()
        .addPermutiveTargeting(permutive)
        .build()

    adView.loadAd(adRequest)
    ```
  </Accordion>
</AccordionGroup>

## Requirements

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

```kotlin theme={"dark"}
dependencies {
    // Core SDK (required)
    implementation("com.permutive.android:core:1.11.3")

    // Optional add-ons
    implementation("com.permutive.android:google-ads:2.2.0")
    implementation("com.permutive.android:appnexus:1.7.0")
}
```

## Key Concepts

<SDKKeyConcepts />

## Additional Resources

<Tabs>
  <Tab title="Guides">
    Best practices, patterns, and how-tos.

    * **[Migration: v1.9.x to v1.10.x](/sdks/mobile/android/guides/migration/v1-9-to-v1-10)** - Upgrade to the latest version

    <Info>
      **Coming Soon:** Architecture Patterns, Testing Strategies, GDPR Compliance, and Performance Optimization guides are being developed.
    </Info>
  </Tab>

  <Tab title="Reference">
    API documentation and technical reference.

    * **[Javadocs](https://sdk-docs.permutive.com/)** - Complete API documentation
    * **[Sample Apps](https://github.com/permutive/android-sdk-samples)** - Example integrations

    <Info>
      **Coming Soon:** Changelog, Minimum Versions, and Event Schema reference documentation.
    </Info>
  </Tab>
</Tabs>

## FAQ

<AccordionGroup>
  <Accordion title="What's the difference between PageTracker and EventTracker?">
    **PageTracker** is the recommended approach for most use cases. It automatically tracks Pageview events, measures engagement time and scroll depth, and enables contextual cohorts when URLs are provided.

    **EventTracker** is for specialized cases where you need to track custom events that don't fit the page model.
  </Accordion>

  <Accordion title="How do I enable debug logging?">
    Enable developer mode in your code:

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

    Or via ADB:

    ```bash theme={"dark"}
    adb shell setprop log.tag.Permutive VERBOSE
    adb logcat -s Permutive
    ```
  </Accordion>

  <Accordion title="What identifiers should I use for identity management?">
    Use hashed emails (SHA-256), internal user IDs, or mobile advertising IDs. Never send plain text PII. See the [Identity Management](/sdks/mobile/android/core-concepts/identity-management) guide for details.
  </Accordion>

  <Accordion title="How long does it take for events to appear in the dashboard?">
    Events typically appear within 5 minutes. If you see "Accepted: 1 / 1" in your debug logs, the event was successfully sent.
  </Accordion>
</AccordionGroup>

## Getting Help

* **[Troubleshooting Guide](/sdks/mobile/android/troubleshooting/common-errors)** - Solutions to common issues
* **Customer Success Manager (CSM)** - For enabling features and exploring use cases
* **[Technical Services](mailto:technical-services@permutive.com)** - For technical setup and configuration
* **[Support](mailto:support@permutive.com)** - For troubleshooting and help

## Privacy & Compliance

Permutive is designed with privacy in mind: GDPR compliant, CCPA compliant, no PII storage, user consent respected, and transparent data usage.
