top of page

Integrating Our Unity Library into Native Android: A Step-by-Step Guide

This document explains how to include our library consisting the games into a standard Android application through Activity.


Requirement:

  • Android Studio Bumblebee (2021.1.1) or later


STEPS:


  1. Place our "Nx_UnityLibrary" folder in the same directory as the Native Android Project, then:

    1. Open settings.gradle file

      1. Add a new project pointing to unityLibrary module after the main app module: include ':unityLibrary' project(':unityLibrary').projectDir=new File('..\\Nx_UnityLibrary\\unityLibrary')

      2. And add the following in dependencyResolutionManagement{repositories{ block: flatDir { dirs "${project(':unityLibrary').projectDir}/libs" }

    2. Open build.gradle(Module: NativeAndroidApp.app) file

      1. Add the following in dependencies{ block: implementation project(':unityLibrary') implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])

    3. Copy the contents of the gradle.properties file from the exported Unity project root folder to the gradle.properties file in the native application root folder. Note: if you update the Unity project and re-export it again, make sure that the contents of the gradle.properties file in the exported project did not change. If they did - repeat this step.

    4. Click Sync Now to do a project sync since Gradle files have been modified


Here is how the settings.gradle file should look.


Here is how the build.gradle(Module: NativeAndroidApp.app) file should look


If everything succeeds, you should see unityLibrary module added in Android view


13 views0 comments

Recent Posts

See All
bottom of page