Start free trial
Table of Content

    Android SDK integration in Unity Project.

    • January 5, 2026
    • 1 mins read

    Table of Content

      To integrate Android SDK with your unity project, please follow the below mentioned steps:

      • In Unity project folder, create Assets/Plugins/Android/ folder
      • Set android related configurations in Unity, from File -> Build Profile (Android platform) and select Player settings.
      • From player settings do following things
        • In Other setting, Minimum API Level 24
        • In Publishing Settings, Check:
          • Custom Main Gradle Template
          • Custom Base Gradle Template
          • Custom Gradle Properties Template
          • Custom Gradle Settings Template
          • Custom Proguard File
      • In mainTemplate.gradle, add the marked lines
      apply plugin: 'com.android.library'
      apply from: '../shared/keepUnitySymbols.gradle'
      apply from: '../shared/common.gradle'
      **APPLY_PLUGINS**
      
      dependencies {
          implementation fileTree(dir: 'libs', include: ['*.jar'])
          // --- CUSTOM DEPENDENCIES START ---
          // Add any Gradle dependencies you need here  
          
          implementation 'androidx.databinding:databinding-common:8.0.0'
          implementation 'androidx.databinding:databinding-runtime:8.0.0'
          annotationProcessor 'androidx.databinding:databinding-compiler:8.0.0'
          
          implementation 'androidx.core:core-ktx:1.16.0'
          implementation 'androidx.appcompat:appcompat:1.6.1'
          implementation 'com.google.android.material:material:1.8.0'
          implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
          testImplementation 'junit:junit:4.13.2'
          androidTestImplementation 'androidx.test.ext:junit:1.1.5'
          androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
          implementation 'com.google.firebase:firebase-messaging:24.0.3'
          implementation('com.revesoft.revechatsdk:revechatsdk:1.0.1-unity')  
          // --- CUSTOM DEPENDENCIES END ---
      **DEPS**}
      
      android {
          namespace "com.unity3d.player"
          ndkPath "**NDKPATH**"
          ndkVersion "**NDKVERSION**"
      
          compileSdk **APIVERSION**
          buildToolsVersion = "**BUILDTOOLS**"
      
          compileOptions {
              sourceCompatibility JavaVersion.VERSION_17
              targetCompatibility JavaVersion.VERSION_17
          }
          
          
          // Enable DataBinding here
          buildFeatures {
              dataBinding  true
              viewBinding true
          }
      
          defaultConfig {
              minSdk **MINSDK**
              targetSdk **TARGETSDK**
              ndk {
                  abiFilters **ABIFILTERS**
                  debugSymbolLevel **DEBUGSYMBOLLEVEL**
              }
              versionCode **VERSIONCODE**
              versionName '**VERSIONNAME**'
              consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
      **DEFAULT_CONFIG_SETUP**
          }
      
          lint {
              abortOnError false
          }
          
          androidResources {
              noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
              ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
          }**PACKAGING**
      }
      
      **IL_CPP_BUILD_SETUP**
      **SOURCE_BUILD_SETUP**
      **EXTERNAL_SOURCES**
      
      • In gradleTemplate.properties
      org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
      org.gradle.parallel=true
      unityStreamingAssets=**STREAMING_ASSETS**
      android.useAndroidX=true
      android.enableJetifier=true
      **ADDITIONAL_PROPERTIES**
      • In settingsTemplate.gradle
      pluginManagement {
          repositories {
              **ARTIFACTORYREPOSITORY**
              gradlePluginPortal()
              google()
              mavenCentral()
          }
      }
      
      include ':launcher', ':unityLibrary'
      **INCLUDES**
      
      dependencyResolutionManagement {
          repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
          repositories {
              **ARTIFACTORYREPOSITORY**
              google()
              mavenCentral()
              maven {
                  url "https://maven.iptelephony.revesoft.com/artifactory/libs-release-local/"
              }
              maven {
                  url "https://jfrog-artifact.revechat.com/artifactory/artifactory/"
              }
              maven { url "https://jitpack.io" }
              flatDir {
                  dirs "${project(':unityLibrary').projectDir}/libs"
              }
          }
      }
      • Add the script in unity project to start the REVEChat SDK activity
      using UnityEngine;
      using System.Collections;   
      
      using UnityEngine;
      using System.Collections;
      
      public class NewMonoBehaviourScript : MonoBehaviour
      {
          public string accountId =   "2552651"; 
          public string userName = "John Doe";
          public string userEmail = "[email protected]";
          public string userPhone = "+123456789";
      
          void Start()
          {
              // Intentionally empty
          }
      
          IEnumerator LaunchReveChatWithDelay()
          {
              yield return null;
              yield return new WaitForSeconds(0.2f);
              InitiateReveChat();
          }
      
          public void InitiateReveChat()
          {
              try
              {
                  // Step 1: Get ReveChat class
                  AndroidJavaClass reveChatClass =
                      new AndroidJavaClass("com.revesoft.revechatsdk.utils.ReveChat");
                  Debug.Log("ReveChat class found!");
      
                  // Step 2: Initialize ReveChat
                  reveChatClass.CallStatic("init", accountId);
                  Debug.Log("ReveChat initialized!");
      
                  // Step 3: Create VisitorInfo
                  AndroidJavaObject visitorBuilder =
                      new AndroidJavaObject("com.revesoft.revechatsdk.model.VisitorInfo$Builder");
      
                  visitorBuilder
                      .Call<AndroidJavaObject>("name", userName)
                      .Call<AndroidJavaObject>("email", userEmail)
                      .Call<AndroidJavaObject>("phoneNumber", userPhone);
      
                  AndroidJavaObject visitorInfo =
                      visitorBuilder.Call<AndroidJavaObject>("build");
      
                  Debug.Log("VisitorInfo created!");
      
                  // Step 4: Set VisitorInfo
                  reveChatClass.CallStatic("setVisitorInfo", visitorInfo);
                  Debug.Log("VisitorInfo set successfully!");
      
                  // Step 5: App info
                  reveChatClass.CallStatic("setAppBundleName", Application.identifier);
                  reveChatClass.CallStatic("setAppVersionNumber", Application.version);
                  reveChatClass.CallStatic("setApiServiceTitle", "REVEChatApiService");
                  reveChatClass.CallStatic("setApiServiceContent", "REVEChatApiService");
                  Debug.Log("App info & API service set!");
      
                  // Step 6: Start ReveChatActivity
                  if (Application.platform == RuntimePlatform.Android)
                  {
                      AndroidJavaClass unityPlayer =
                          new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                      AndroidJavaObject currentActivity =
                          unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
      
      
                      currentActivity.Call(
                          "runOnUiThread",
                          new AndroidJavaRunnable(() =>
                          {
                              AndroidJavaObject intent =
                                  new AndroidJavaObject("android.content.Intent");
      
                              intent.Call<AndroidJavaObject>(
                                  "setClassName",
                                  currentActivity.Call<string>("getPackageName"),
                                  "com.revesoft.revechatsdk.ui.activity.ReveChatActivity"
                              );
      
      
                             
                              intent.Call<AndroidJavaObject>(
                                  "addFlags", 0x10000000 // FLAG_ACTIVITY_NEW_TASK
                              );
      
                              currentActivity.Call("startActivity", intent);
                          })
                      );
                  }
              }
              catch (System.Exception e)
              {
                  Debug.LogError("Unexpected error in InitiateReveChat: " + e.Message);
              }
          }
      }
      

      AUTHOR’S BIO

      Rahat Hassan is a strategic Product Marketing Manager at REVE Chat specializing in customer experience & communication. He is passionate about creating compelling content for diverse audiences. Beyond work, he enjoys reading articles and watching videos on trending technological shifts ...

      0:00 / 0:00