# adjust/android_sdk architecture

> Architecture diagram of the GitHub repository adjust/android_sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adjust/android_sdk
- Repository: https://github.com/adjust/android_sdk

## Overview

##### Project Type and Purpose
- This is an Android SDK library that offers core functionality (in the sdk-core directory) and extended features through a number of plugins (found in the plugins directory). These plugins (such as those for Huawei, Xiaomi, Samsung, and others) are meant to provide integrations with various device-specific or third-party services.
- Alongside these, there are multiple examples organized by language (Java, Kotlin) and use-cases (e.g., keyboard integration, webbridge) that demonstrate how to integrate and use the Adjust SDK in different Android applications. There are also tests that help ensure reliability and correct behavior.

##### Key Components (from File Structure)
- Adjust/sdk-core: This is the heart of the system that contains the core classes and functionalities (e.g., Adjust.java, ActivityHandler.java, network modules, schedulers, etc.). It provides the main interfaces and handles operations like event tracking, session management, and attribution.
- Adjust/plugins: Each subfolder here represents a plugin module that extends the SDK’s functionality. They add support for various device-specific or data-gathering features (e.g., imei, meta-referrer, oaid, and integrations with Samsung, Huawei, Vivo, and Xiaomi). These plugins usually have their own implementation modules and resources.
- Examples: There are multiple sample projects (e.g., example-app-java, example-app-kotlin, example-app-fbpixel, etc.) that show how to use the SDK in different configurations and application scenarios. They include standard Android project structures with manifests, activities, resources, and sometimes, assets.
- Tests: The tests directory contains test applications and test libraries that ensure the core and plugin functionalities work as expected.

##### Relationships, Interactions, and Architectural Patterns
- The core SDK acts as the foundation and provides a set of public APIs (via Adjust.java and supporting classes) that get called from within an Android application. It manages the overall flow including activity monitoring, network communication (packaged inside the network and scheduler submodules), and persistence (via shared preferences and internal state management).
- The plugins build upon the core SDK and add vendor-specific integrations. They are designed in a modular way so that they can be integrated or omitted depending on the application’s requirements.
- The sample projects depend on the core SDK (and any required plugins) to illustrate integration. They typically initialize the SDK (through configuration classes such as AdjustConfig) in their Application classes or activities.
- The system is largely event-driven. Android lifecycle callbacks and asynchronous networking/scheduling (in components such as ThreadScheduler or SingleThreadFutureScheduler) drive the interactions between the app, core SDK, and plugins.
- The SDK is architected to interact with the Android framework in typical ways (e.g., via content providers, broadcast receivers for referrer events, etc.), and provides multiple listener interfaces for callbacks (e.g., OnAttributionChangedListener, OnDeeplinkResolvedListener) that allow the app to respond to events.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Android Application Integration Layer
    subgraph "Android Integration Layer"
        E1["Example App Java"]:::app
        E2["Example App Kotlin"]:::app
        E3["Example App FB Pixel"]:::app
    end

    %% SDK Core and its subcomponents
    subgraph "SDK Core"
        C1["Adjust SDK Core"]:::core
        C2["ActivityHandler"]:::core
        C3["Network Module"]:::util
        C4["Scheduler"]:::util
        C5["Callback Listeners"]:::core
    end

    %% Plugins and Testing Modules
    P["Plugins (Vendor-specific)"]:::plugin
    T["Testing Modules"]:::test

    %% Connections from Sample Apps to SDK Core
    E1 -->|"calls"| C1
    E2 -->|"calls"| C1
    E3 -->|"calls"| C1

    %% Internal SDK Core interactions
    C1 -->|"manages"| C2
    C1 -->|"schedules"| C4
    C1 -->|"communicates"| C3
    C1 -->|"notifies"| C5

    %% SDK Core plugin integration
    C1 -->|"integrates"| P

    %% Testing Modules interaction
    T -->|"validates"| C1

    %% Callback from SDK back to Android App
    C5 -->|"callbacks"| E1
    C5 -->|"callbacks"| E2
    C5 -->|"callbacks"| E3

    %% Click Events
    click C1 "https://github.com/adjust/android_sdk/tree/master/Adjust/sdk-core"
    click P "https://github.com/adjust/android_sdk/tree/master/Adjust/plugins"
    click E1 "https://github.com/adjust/android_sdk/tree/master/Adjust/examples/example-app-java"
    click E2 "https://github.com/adjust/android_sdk/tree/master/Adjust/examples/example-app-kotlin"
    click E3 "https://github.com/adjust/android_sdk/tree/master/Adjust/examples/example-app-fbpixel"
    click T "https://github.com/adjust/android_sdk/tree/master/Adjust/tests"
    click C4 "https://github.com/adjust/android_sdk/tree/master/Adjust/sdk-core/src/main/java/com/adjust/sdk/scheduler"
    click C3 "https://github.com/adjust/android_sdk/tree/master/Adjust/sdk-core/src/main/java/com/adjust/sdk/network"

    %% Styling
    classDef app fill:#FFECB3,stroke:#FF9800,stroke-width:2px;
    classDef core fill:#BBDEFB,stroke:#1976D2,stroke-width:2px;
    classDef plugin fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef test fill:#FFCDD2,stroke:#D32F2F,stroke-width:2px;
    classDef util fill:#FFE082,stroke:#FBC02D,stroke-width:2px;
```
