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

   <img src="https://mintcdn.com/appcharge/pgQNefK6v2mrfKWg/images/sdks/unity/config_android_main.png?fit=max&auto=format&n=pgQNefK6v2mrfKWg&q=85&s=6be89f68e773d1efac83157a1113f9e7" alt="Android Build Settings" width="258" data-path="images/sdks/unity/config_android_main.png" />

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`)

   <img src="https://mintcdn.com/appcharge/pgQNefK6v2mrfKWg/images/sdks/unity/config_editor_android.png?fit=max&auto=format&n=pgQNefK6v2mrfKWg&q=85&s=939e9bcbebf8b97daac775a391e351da" alt="Android Editor Configurations" width="349" height="356" data-path="images/sdks/unity/config_editor_android.png" />

4. Your configuration settings should look like this:

   <img src="https://mintcdn.com/appcharge/pgQNefK6v2mrfKWg/images/sdks/unity/config_android.png?fit=max&auto=format&n=pgQNefK6v2mrfKWg&q=85&s=88fa5880520c9afeb17acacde9a5a1d7" alt="Android Configurations" width="659" height="661" data-path="images/sdks/unity/config_android.png" />

   <Note> By default, the configuration file is preconfigured for integration. However, you must set the required **Environment** and **Checkout Public Key** fields under **Publisher Info**. </Note>

   ## Publisher Info

   <Note> These settings can also be changed at runtime, but doing so requires [re-initializing the SDK](./initialize-the-payment-links-sdk#re-initialize-the-sdk). </Note>

   | Property            | Value    | 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**. |

   ## Platform Auto Integration Settings

   | Property             | Value  | Description                                                                                                                                       |
   | -------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
   | Android Browser Mode | `Enum` | Sets how the checkout is opened. Use `TWA` for Trusted Web Activity, `CCT` for Custom Chrome Tab, or `External` for the device's default browser. |

   ### Gradle Properties

   These settings automatically modify your `AndroidManifest.xml` and Gradle files to include all necessary dependencies at build time.\
   You can choose to exclude or disable specific dependencies based on your project’s needs.

   | Property          | Value     | Description                                                                      |
   | ----------------- | --------- | -------------------------------------------------------------------------------- |
   | 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
   ```

   ### Gradle Dependencies

   | Property                          | Value     | 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 Coroutine 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**
   }

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

   ### Manifest Modifications

   | Property                                  | Value     | 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                | `Boolean` | Exclude the Appcharge Checkout activity.                                     |
   | Exclude Exported Attribute                | `Boolean` | Exclude the `android:exported` attribute from the Checkout activity.         |
   | Exclude Discouraged Api Tool              | `Boolean` | Exclude `<tools:ignore="DiscouragedApi">` from the Checkout activity.        |
   | Exclude Appcharge Activity Intent Filters | `Boolean` | Exclude intent filters from the Appcharge Checkout activity.                 |
   | Exclude Custom Scheme                     | `Boolean` | Exclude the `<data android:scheme="acnative-{gameNameLowerCase}">` entry.    |
   | Exclude Custom Host                       | `Boolean` | Exclude the `<data android:host="action">` entry.                            |
   | Exclude Https Scheme In Activity          | `Boolean` | Exclude the `<data android:scheme="https">` entry from the intent filter.    |

   <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.
   </Note>

   ### Example Manifest

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

   <CodeGroup>
     ```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.core.CheckoutActivity" android:exported="true">
       <!-- Custom scheme -->
       <intent-filter android:autoVerify="true">
         <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" />
         <data android:scheme="https" />
       </intent-filter>
     </activity>
     <!-- Foreground service declaration -->
     <service android:name="com.appcharge.paymentlinks.CheckoutService" 
     android:exported="false" 
     android:foregroundServiceType="shortService" />  
     </application>
     </manifest>
     ```
   </CodeGroup>

   <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).
   </Warning>

   ### General Auto Integration Settings

   | Property                   | Value     | Description                                                                                                                                                |
   | -------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | Enable Integration Options | `Boolean` | Determines whether the SDK automatically applies required Xcode configurations during build. If disabled, you’ll need to configure them manually in Xcode. |
   | Enable Debug Mode          | `Boolean` | Enable this to print a summary of the automatic integration changes after the build.                                                                       |

   <Warning>
     Disabling **Enable Integration Options** prevents automatic configuration required for the Checkout SDK from functioning correctly. If disabled, you must manually configure each required file.
   </Warning>
