How to integrate your Unity Program to Android Studio


This last couple days, I try to integrate my program in unity with android studio. I am not an expert in both platform but I try to learn it for my class project. To be honest, I have experience working with android studio, for me it is a really good tool to build your android apps, however if you want to develop a games app, it will be little difficult working in this platform. That is why, I try to work with unity, but this is really unfamiliar environment for me, so to make my project can be done, I try to combine both this two tools.

I don`t know this is a stupid idea or not, but maybe some of you want to use this method, then I will help you.

1. Install both android studio and unity in your PC (Don`t worry both are free)

2. Build your apps in both platforms, in my case I build spotify like program in android studio and the game apps in unity.

3. If you done with the design in both platforms. Go to unity and go to Edit -> Preferences ->External Tools. You must locate the SDK and JDK location in your computer. If you don´t know the location of SDK, just open your android studio and click SDK manager button, and new windows will open, and see SDK android location in that windows.

The Preferences window in Unity, to Locate your SDK and JDK

For JDK, if you don´t have one, just download it in and choose the new java development kit provide by oracle, after that just install it in your laptop and don´t forget to remember the location of that file.

4. After you located both those file, right know you able to build your android program from unity. To make sure you can combine your unity program with android studio, copy your android manifest.xml file from android studio than in unity in assets folder make new folder name plugins, and inside plugins make new folder name android. After that paste the manifest.xml in this folder.

Copy your android manifest.xml file to unity after make this folder

5. if you already copied the manifest.xml, then in unity go to file -> build settings. In platform choose android, and choose this settings.

Go to build settings to create your android studio project from unity

6. After that you will get new file that have same type with android studio. Open that file you already build from unity in android studio.

android studio
Gradle have finished the build, move the files from your android studio project that you want to combine to this file

7. After open the unity file in android studio it will build gradle. Then the gradle build finish, move the java and res file from your android studio project you want to combine with unity. Because you already copied the manifest file so, in this unity project android studio will follow that manifest file. If there is no folder like raw, or drawable in unity android studio, just crate one.

8. Don`t forget to change the package name in your java folder, it must follow the unity package name, you can see the example in file

Don`t forget change the package name from your previous java file to unity android studio project.

9. Don`t forget to create button and intent that will open this file, to go to Unity layout game

android studio
Create button and intent to move to Unity game

10 At the end, go to manifest.xml in unity android studio project. And put activity in that mainfest or copy this script below, with some change in android:name part Then build your program in Android studio

<activity android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" 
  <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
android studio
Copy that part to android manifest in unity project, change the name name part

After that just build the file in android studio.

The result below:




(Visited 98 times, 1 visits today)

Leave a Reply