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

# Integrate with Android

This article explains how to integrate Unity Payment Links with the Android platform.

To integrate with Android:

1. Go to the **Build Settings** window and make sure your Unity project is set to **Android**. Once set, the `AppchargeConfig` file updates to display Android-specific configuration options.

   ![Android Build Settings](https://mintcdn.com/appcharge/pgQNefK6v2mrfKWg/images/sdks/unity/config_android_main.png?fit=max\&auto=format\&n=pgQNefK6v2mrfKWg\&q=85\&s=6be89f68e773d1efac83157a1113f9e7)

2. Click **Player Settings > Publisher Settings**, and scroll to the **Build** section.

3. Expose (enable) the following android plugin files or the build process will be passed without changes:

   * Custom Main Manifest (`AndroidManifest.xml`)
   * Custom Main Gradle Template (`mainTemplate.gradle`)
   * Custom Gradle Properties Template (`gradleTemplate.properties`)

   ![Android Editor Configurations](https://mintcdn.com/appcharge/pgQNefK6v2mrfKWg/images/sdks/unity/config_editor_android.png?fit=max\&auto=format\&n=pgQNefK6v2mrfKWg\&q=85\&s=939e9bcbebf8b97daac775a391e351da)

4. Your configuration settings should look like this:

   ![Android Configurations](https://mintcdn.com/appcharge/aHvkQM4kEbqf_uft/images/sdks/unity/config_android.png?fit=max\&auto=format\&n=aHvkQM4kEbqf_uft\&q=85\&s=9de9b0602b70ee0626421ee7ccd426d4)

   ## Publisher Info

   > [!NOTE]
   >
   > These settings can also be changed at runtime, but doing so requires [re-initializing the SDK](https://docs.appcharge.com/sdks/payment-links/unity/initialize-the-payment-links-sdk.md#re-initialize-the-sdk).

   | Property | Type | Description |
   | - | - | - |
   | Environment | `Enum` | Sets the checkout environment. Use `Sandbox` for testing and `Production` for live payments. |
   | Checkout Public Key | `String` | Defines the checkout public key. You can find it by going to the **Publisher Dashboard → Settings → Integration**. |

   ## Configuration Settings

   | Property | Type | Description |
   | - | - | - |
   | Enable Main Thread Dispatcher | `boolean` | The SDK works outside of the Unity main thread. This option allows you to wrap callback methods with Unity main thread. |
   | Enable Debug Mode | `Boolean` | When enabled, prints a summary of automatic integration changes after the build completes. |
   | Browser Mode | `Enum` | Sets how the checkout is opened. Use `External` for the device's default browser or `Internal` for Trusted Web Activity (TWA). |

   ## Integration Settings

   Enables automatic integration of required Android dependencies and manifest entries during the build process.

   > [!WARNING]
   >
   > Use the following options to exclude parts of the build process. By doing so, you may need to implement part of the process manually.

   | Property | Type | Description |
   | - | - | - |
   | Enable Integration Options | `Boolean` | Determines whether the SDK automatically applies required Android configurations during build. If disabled, you’ll need to configure them manually. |
   | Exclude Android X | `Boolean` | Exclude the `useAndroidX` property from the `gradleTemplate.properties` file. |
   | Exclude Jetifier | `Boolean` | Exclude the `enableJetifier` property from the `gradleTemplate.properties` file. |

   ```
   **Unity Standart Settings goes here**
   **ADDITIONAL_PROPERTIES**
   android.useAndroidX=true
   android.enableJetifier=true
   ```

   | Property | Type | Description |
   | - | - | - |
   | Exclude Core Ktx | `Boolean` | Exclude Kotlin core dependency from the `mainTemplate.gradle` file. |
   | Exclude Activity Ktx | `Boolean` | Exclude Kotlin activity dependency from the `mainTemplate.gradle` file. |
   | Exclude Android Browser Helper | `Boolean` | Exclude the `AndroidBrowserHelper` dependency from the `mainTemplate.gradle` file. |
   | Exclude Android X Browser | `Boolean` | Exclude the `Android X` dependency from the `mainTemplate.gradle` file. |
   | Exclude Kotlin Serialization Json | `Boolean` | Exclude the `Serialization` dependency from the `mainTemplate.gradle` file. |
   | Exclude Kotlin Coroutines Core | `Boolean` | Exclude the `Coroutine Core` dependency from the `mainTemplate.gradle` file. |

   ```
   **---------------**

   dependencies {    
       implementation fileTree(dir: 'libs', include: ['*.jar'])
       
       implementation 'androidx.core:core-ktx:1.13.1'
       implementation 'androidx.activity:activity-ktx:1.3.0'
       implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0'
       implementation 'androidx.browser:browser:1.8.0'
       implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1'
       implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
       **DEPS**
   }

   **---------------**
   ```

   | Property | Type | Description |
   | - | - | - |
   | Exclude Internet Permission | `Boolean` | Exclude the Internet permission from `AndroidManifest.xml`. |
   | Exclude Queries Block | `Boolean` | Exclude Appcharge’s HTTPS scheme query block from the manifest. |
   | Exclude Checkout Service | `Boolean` | Exclude the checkout foreground service permissions and service declaration. |

   ### Exclude Appcharge Activity

   By default, the SDK adds the Appcharge Checkout activity, its exported attribute, and the deeplink intent filter to `AndroidManifest.xml`. Use the options below to skip parts of that setup if you manage them in your own manifest.

   | Property | Type | Description |
   | - | - | - |
   | Exclude Appcharge Activity | `Boolean` | Skips adding the Appcharge Checkout activity declaration. |
   | Exclude Exported Attribute | `Boolean` | Skips adding `android:exported="true"` on the Checkout activity. |
   | Exclude Discouraged Api Tool | `Boolean` | Skips adding `<tools:ignore="DiscouragedApi">` on the Checkout activity. |
   | Exclude Appcharge Activity Intent Filters | `Boolean` | Skips adding the deeplink intent filters on the Checkout activity. |
   | Exclude Custom Scheme | `Boolean` | Skips adding the `<data android:scheme="acnative-{gameNameLowerCase}">` deeplink entry. |
   | Exclude Custom Host | `Boolean` | Skips adding the `<data android:host="action">` deeplink entry. |

   > [!NOTE]
   >
   > * If **Exclude Checkout Service** isn't checked, the SDK automatically adds the required permissions and the `CheckoutService` declaration to your manifest file without duplicating existing permissions. If **Exclude Checkout Service** is checked, the SDK doesn't modify your manifest file.
   > * If you're upgrading an existing integration that already includes the `CheckoutService` declaration, update `android:foregroundServiceType` from `dataSync` to `shortService` in your manifest.

   ### Example Manifest

   If the options above are **not** excluded (disabled), your final Manifest will look like this:

   ```xml xml theme={"system"}
   <?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
   <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
   <!-- Required permissions for foreground service -->
   <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
   <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
   <queries>
   <intent>
     <action android:name="android.intent.action.VIEW" />
     <data android:scheme="https" />
   </intent>
   </queries>
   <application android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
   <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
     <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
     <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
   </activity>
   <activity
     android:name="com.appcharge.paymentlinks.CheckoutActivity"
     android:exported="true"
     android:configChanges="orientation|screenSize"
     android:launchMode="singleTask">
     <!-- Custom scheme -->
     <intent-filter>
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
         <category android:name="android.intent.category.BROWSABLE" />
         <data android:scheme="acnative-{IDENTIFIER}"/>
         <data android:host="action"/>
     </intent-filter>
   </activity>
   <!-- Foreground service declaration -->
   <service android:name="com.appcharge.paymentlinks.CheckoutService" 
   android:exported="false" 
   android:foregroundServiceType="shortService" />  
   </application>
   </manifest>
   ```

   > [!WARNING]
   >
   > The **`intent-filter`** includes a scheme **`"acnative-{IDENTIFIER}"`**. Change the **\{IDENTIFIER}** to the last sequence of your package name. For example, if your package name is **`com.appcharge.mysupergame`**, the identifier will be **`mysupergame`**.
   >
   > This name must be lowercase with no spaces, according to the [Android code style guide](https://source.android.com/docs/core/architecture/hidl/code-style).
