How to export a game or App from Unity to Android

Introduction

In this article we see how to export a game from Unity to Android and look at some of the problems we may encounter in the process and how to fix them.

In the following link you can see the basic setup to export a Unity project to Android, creating a 32 and 64 bits version that can be uploaded to Google Play, I also show how I solved an annoying error with the message “IL2CPP.exe did not run properly”.


Download Unity and the Android package

When installing Unity we must make sure we also download the Android package, so if you haven’t done this or don’t remember it, it’s a good opportunity to download the latest version of Unity along with all the necessary packages.

In particular I like to see all available versions, so in Google I usually search with the term “unity version download”, which leads me to the page with all versions (first page in figure 1).

Fig. 1: We look for the page that contains all versions of Unity.

From there we will access a page like the one shown in figure 2, in my case, because my connection is somewhat unstable, I download Unity using torrent.

Fig. 2: In the list we have several options to download Unity.

Fig. 3: In my case I download the latest version by torrent.

Clicking the highlighted option in Figure 3 automatically downloads a torrent file.

Fig. 4: Downloading the torrent file and open it.

We will need to download the Unity editor and the Android Build Support, in figure 5 are selected the necessary packages.

Fig. 5: In the torrent window we choose the necessary files, in this case we need at least the two selected files.

Configure Android SDK y JDK

To export our Unity games to Android we need to use some external tools, the Android Software Development Kit and the Java Development Kit.

If you don’t have these two kits installed, I’ll show you some screenshots and download links later, for now let’s assume they are installed and move on to the Unity part.

Enter Edit > Preferences and go to the External Tools part, there must be fields to indicate the path of the Android SDK and JDK, as seen at the bottom of figure 6.

Fig. 6: In the preferences window we go to the External Tools part.

By clicking on Browse, we indicate the path of these two development kits. The default installation path of the Android SDK is shown in figure 7, please note that the AppData folder could be hidden.

The path of the JDK is shown in Figure 8, inside program files, Java.

Fig. 7: This is the location of the Android SDK, if you do not find this on your disc read below.

Fig. 8: This is the location of the JDK, if you do not find this on your disk read below.

Configure Unity for the Android Platform

Now we must tell Unity the type of platform we want to export to, in this case Android. To do this, go to File > Build Settings and a window like the one shown in figure 9 will be displayed.

Fig. 9: In the Build Settings tab we select the Android platform and put Switch Platform.

In this window we select the option Android and click on Switch Platform, with this Unity makes a background work and after a moment the project is already adapted to work with Android.

Before creating a compilation we need to set up a few more things.

Go to the project’s Player window, in the Edit > Project Settings > Player tab.

Fig. 10: Let’s go to Edit > Project Settings > Player, to make the necessary settings to export from Unity to Android.

Here we can enter our brand, the name of the game, icons, Google Play keys, among other things.

Fig. 11: Here we can put the name of our Studio and the name of the Game.

At this time we are interested in creating an APK version of the game to test on an Android device, so let’s go directly to the “Other Settings” part and in the field called “Package Name” we have to indicate an identification name that will have in Android.

This is mostly to differentiate our application from all others in existence. The structure of this name should be like this: “com.Company.ProductName”.

For example if GameDevTraum creates a game called “Maze”, the name of the package could be: com.gamedevtraum.maze. It does not need to match a web domain.

In figure 13 we see that I simply used the name: com.mycompany.proyecto1 and this already allowed me to create an Android build.

Fig. 12: A package name is required in order to compile for Android.

Fig. 13: Example of package name.

This package name will appear for example in the Android folder of our device.

Fig. 14: The package name is the name of the application installation folder.

With this we can basically export our game from Unity to Android, go back to the Build Settings window and click on Build and Run.

Fig. 15: With this we are ready to compile, in the Build Settings window we click on Build and Run.

Here we must enter a location and a name for the final file. When you hit Save, the compilation process begins and when it finishes, you have an .apk file that you can install on an API-compatible Android device.

Fig. 16: You will be asked to select a location and a name for the file exported from Unity to Android.

Fig. 17: When the compilation process is finished we will have an .apk file to install in Android.

Unknown sources

By default Android devices reject applications that come from unknown sources, i.e. that are not signed and approved.

To test our game we must allow this type of application to be installed. We can do it from the Android configuration, in my case from “Screen Lock and Security”. You can also do it from the installer and indicate that it is allowed only for that particular installation, that way we will keep rejecting applications from unknown sources.

Fig. 18: At this point, to install the game in an Android device we must accept the unknown sources, this can be done directly from the installer.

We installed the application on our Android and can now test it. In my case I used directly the Android Studio emulator, as you can see in figure 19.

Fig. 19: Testing the application from the Android Studio emulator

Development Kits Downloads

Android SDK

On the Android Studio download page you can get the Android SDK.

There are two ways to install it, one is to download and install the complete Android Studio program. The other way is to download only the Android SDK, scrolling on the same page you will find the downloads. Figures 20 and 21.

Fig. 20: A quick way to get the Android SDK is to directly install Android Studio.

Fig. 21: The Android SDK can also be downloaded individually.

Java Development Kit (JDK)

You can download this JDK from the Java Development Kit download page. In figure 22 we see the download page, we must accept the license terms and then choose the appropriate package for our operating system.

Fig. 22: Java Development Kit (JDK) download page

Environment Variables

Some years ago it was necessary to manually add some Environment variables to the operating system in order to create Android applications. I think this is no longer necessary, but anyway if all the above has not worked I leave you some information about these environment variables to guide you and you can find a solution.

In the following video you can see how to check if you already have this environment variable defined and how to define it if not.

ADD Environment Variables to the system
👉

If we write “Environment Variables” in the Windows search bar, the option “Edit system environment variables” appears, as shown in figure 23.

When entering this option, the system properties window appears and there we have a button to view and edit the System Environment Variables.

In my case it was not necessary to add them manually so I will not go further than this, with this base you can search the web for some solution to the particular problem you have.

Fig. 23: Some time ago it was necessary to create some environment variables in order to create Android applications.

Fig. 24: Location of environment variables to be added or modified

Exit mobile version
Secured By miniOrange