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

# SDK Initialization

> Initialize the Twinalyze Analytics SDK in your Android application.

#### Add the SDK Dependency

Add the following dependency to your app-level `build.gradle` file.

<CodeGroup>
  ```kotlin Kotlin theme={null}
  implementation("com.twinalyze:analytics:1.2.20")
  ```

  ```groovy Java theme={null}
  implementation 'com.twinalyze:analytics:1.2.20'
  ```
</CodeGroup>

In your project-level `build.gradle`, make sure the following plugins are configured:

<CodeGroup>
  ```kotlin Kotlin theme={null}
  plugins {
      id("com.android.application") version "8.13.2" apply false
      id("org.jetbrains.kotlin.android") version "2.0.21" apply false
      id("org.jetbrains.kotlin.plugin.compose") version "2.0.21" apply false
  }
  ```

  ```groovy Java theme={null}
  plugins {
      id 'com.android.application' version '8.13.2' apply false
      id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
      id 'org.jetbrains.kotlin.plugin.compose' version '2.0.21' apply false
  }
  ```
</CodeGroup>

#### Initializing Analytics SDK in Android

Initialize the SDK in your `Application` class to start tracking sessions, events, and insights.

<CodeGroup>
  ```kotlin Kotlin theme={null}
  Twinalyze.initialize(
      this,
      "YOUR_API_KEY",
      "YOUR_SECRET_ID",
      object : TwinalyzeInitializationStatus {
          override fun onSuccess() {

          }

          override fun onFailed(twinalyzeError: TwinalyzeError) {

          }
      }
  )
  ```

  ```java Java theme={null}
  Twinalyze.initialize(
      this,
      "YOUR_API_KEY",
      "YOUR_SECRET_ID",
      new TwinalyzeInitializationStatus() {
          @Override
          public void onSuccess() {

          }

          @Override
          public void onFailed(TwinalyzeError twinalyzeError) {

          }
      }
  );
  ```
</CodeGroup>

**Parameter Reference**

| Parameter     | Description                 |
| ------------- | --------------------------- |
| `application` | Android application context |
| `apiKey`      | Your API key                |
| `secretKey`   | Your project secret key     |

<div className="twinalyze-sdk-demo not-prose">
  <div className="twinalyze-sdk-demo-card">
    <div className="twinalyze-sdk-demo-key">
      <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
        <path d="M15.5 3.5a5 5 0 0 0-4.72 6.65L3 17.93V21h3.07l1.5-1.5H10V17h2.5l1.35-1.35A5 5 0 1 0 15.5 3.5Z" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />

        <circle cx="16.5" cy="8.5" r="1" fill="currentColor" />
      </svg>
    </div>

    <div className="twinalyze-sdk-demo-title">
      Demo Account
    </div>

    <div className="twinalyze-sdk-demo-detail">
      <span>Email:</span>

      <a href="mailto:support@twinalyze.com">
        [support@twinalyze.com](mailto:support@twinalyze.com)
      </a>
    </div>

    <div className="twinalyze-sdk-demo-detail">
      <span>Password:</span>
      <span>demo\@123</span>
    </div>
  </div>

  <div className="twinalyze-sdk-demo-links">
    <a href="https://github.com/twinalyze/twinalyze-android-food-delivery-app-demo.git" target="_blank" rel="noreferrer" className="twinalyze-sdk-demo-link">
      <svg width="22" height="22" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
        <path d="M12 2C6.48 2 2 6.48 2 12c0 4.42 2.87 8.17 6.84 9.49.5.09.68-.22.68-.48 0-.24-.01-1.03-.01-1.87-2.78.6-3.37-1.18-3.37-1.18-.45-1.16-1.11-1.47-1.11-1.47-.91-.62.07-.61.07-.61 1 .07 1.53 1.03 1.53 1.03.9 1.53 2.35 1.09 2.92.83.09-.65.35-1.09.64-1.34-2.22-.25-4.56-1.11-4.56-4.97 0-1.1.39-1.99 1.03-2.7-.1-.25-.45-1.27.1-2.66 0 0 .84-.27 2.75 1.03A9.55 9.55 0 0 1 12 6.84c.85 0 1.7.11 2.5.33 1.91-1.3 2.75-1.03 2.75-1.03.55 1.39.2 2.41.1 2.66.64.71 1.03 1.6 1.03 2.7 0 3.87-2.34 4.71-4.57 4.96.36.31.68.93.68 1.88 0 1.36-.01 2.47-.01 2.81 0 .27.18.58.69.48A10 10 0 0 0 22 12C22 6.48 17.52 2 12 2Z" />
      </svg>

      <span>Github Demo</span>
    </a>

    <span className="twinalyze-sdk-demo-divider" />

    <a href="https://drive.google.com/drive/folders/1czFBkIDrxdkPcQRpOcrwFnjzPujvh7K7" target="_blank" rel="noreferrer" className="twinalyze-sdk-demo-link">
      <svg width="23" height="23" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" className="twinalyze-sdk-android-icon">
        <path d="M7.2 6.35 5.9 4.1a.5.5 0 1 1 .87-.5l1.32 2.28A8.55 8.55 0 0 1 12 5c1.4 0 2.73.32 3.91.88l1.32-2.28a.5.5 0 1 1 .87.5l-1.3 2.25A7.51 7.51 0 0 1 20 12H4a7.51 7.51 0 0 1 3.2-5.65ZM8 9.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm8 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM4 13h16v6.5A1.5 1.5 0 0 1 18.5 21H17v-5.5a.5.5 0 0 0-1 0V21H8v-5.5a.5.5 0 0 0-1 0V21H5.5A1.5 1.5 0 0 1 4 19.5V13Z" />
      </svg>

      <span>Download APK</span>
    </a>

    <span className="twinalyze-sdk-demo-divider" />

    <a href="https://app.twinalyze.com/" target="_blank" rel="noreferrer" className="twinalyze-sdk-demo-link">
      <svg width="23" height="23" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
        <rect x="3" y="15" width="4" height="6" rx="1" fill="#2563EB" />

        <rect x="10" y="9" width="4" height="12" rx="1" fill="#3B82F6" />

        <rect x="17" y="3" width="4" height="18" rx="1" fill="#60A5FA" />
      </svg>

      <span>Demo</span>
    </a>
  </div>

  <div className="twinalyze-sdk-best-practice">
    <div className="twinalyze-sdk-best-practice-title">
      <span className="twinalyze-sdk-check-icon">
        ✓
      </span>

      <span>Best Practice</span>
    </div>

    <p>
      Always call <code>initialize()</code> inside your{" "}
      <code>Application</code> class — not inside an Activity — to ensure
      complete session tracking.
    </p>
  </div>
</div>

<CodeGroup>
  ```kotlin Kotlin theme={null}
  Twinalyze.initialize(
      this,
      "YOUR_DEMO_API_KEY",
      "YOUR_DEMO_SECRET_ID",
      object : TwinalyzeInitializationStatus {
          override fun onSuccess() {

          }

          override fun onFailed(twinalyzeError: TwinalyzeError) {

          }
      }
  )
  ```

  ```java Java theme={null}
  Twinalyze.initialize(
      this,
      "YOUR_DEMO_API_KEY",
      "YOUR_DEMO_SECRET_ID",
      new TwinalyzeInitializationStatus() {
          @Override
          public void onSuccess() {

          }

          @Override
          public void onFailed(TwinalyzeError twinalyzeError) {

          }
      }
  );
  ```
</CodeGroup>

#### Add proguard file

Add the following rules to your `proguard-rules.pro` file:

```text proguard-rules.pro theme={null}
-keepnames class * extends android.app.Activity
-keepnames class * extends androidx.appcompat.app.AppCompatActivity
-keepnames class * extends androidx.fragment.app.FragmentActivity
-keepnames class * extends androidx.fragment.app.Fragment
-keep class com.twinalyze.** { *; }
```

***

<div className="twinalyze-bottom-nav">
  <a href="/sdks/app/analytics/get-started" className="twinalyze-nav-side">
    <span className="twinalyze-nav-arrow">‹</span>
    <span>Previous</span>
  </a>

  <a href="/sdks/app/analytics/custom-event-tracking" className="twinalyze-nav-center">
    <strong>Custom Event Tracking</strong>
    <span>Track custom user actions in your Android app.</span>
  </a>

  <a href="/sdks/app/analytics/custom-event-tracking" className="twinalyze-nav-side">
    <span>Next</span>
    <span className="twinalyze-nav-arrow">›</span>
  </a>
</div>
