Creating a game on the Unity engine opens up enormous opportunities for the developer, but real success comes only when the project falls into the hands of users. Porting a game to the Android platform is one of the most critical stages in the product life cycle, since it is the mobile segment that dominates the interactive entertainment market. This process requires not just pressing the โ€œBuildโ€ button, but a deep understanding of the architecture of mobile devices, performance limitations and the specifics of the operating system.

Unlike desktop development, where system resources are often redundant, the mobile environment imposes strict limits on power consumption, heating and the amount of RAM. Porting a Unity game to Android turns into a complex engineering process, including setting up the environment, adapting controls for touch screens and graphics optimization for various chipsets. Errors at this stage can lead to the fact that even a game that is brilliant in gameplay will be uninstalled by users due to crashes or low FPS.

In this article we will analyze in detail the entire path from setting up the project to the final compilation of the release version. We will look at hidden engine settings, working with Android SDK i NDK, as well as methods for diagnosing problems that arise exclusively on mobile devices. Proper preparation at the start will save you hundreds of hours of debugging in the future.

Preparing the environment and setting up the project

The first step before starting work is to install all the necessary components, without which assembly for Android is impossible. You will need not only the Unity engine itself, but also additional tools from Google, which provides communication between the C# code and the smartphone hardware. Installation Android Build Support via Unity Hub automates part of the process, but manual checking of SDK and NDK versions is often necessary to avoid compatibility conflicts.

After installing the modules, you need to go to the project settings through the menu Edit โ†’ Project Settings โ†’ Player. Here is a panel Android Settingswhere you set the fundamental parameters of your application. Particular attention should be paid to the field Package Name, which must be a unique identifier in the format com.companyname.productname. Changing this setting after publication in the store is impossible without creating a new application.

Also at this stage, the minimum version of the operating system is selected. Setting the value too low Minimum API Level may expand your audience, but will make it more difficult to support modern features and libraries. On the contrary, a high entry threshold will exclude owners of older devices, but will allow the use of more advanced graphics API capabilities.

โš ๏ธ Attention: Android SDK and NDK versions must strictly meet the requirements of your version of Unity. Using incompatible versions often leads to compilation errors that are difficult for a beginner to diagnose.

โ˜‘๏ธ Environment readiness

Done: 0 / 4

Configuration of graphics settings and rendering

Mobile devices have significantly less processing power compared to PCs, so the choice of graphics API is a decisive factor in performance. In the player settings in the section Other Settings you must select Graphics API. For modern devices, the de facto standard has become Vulkanwhich provides better memory efficiency and multi-threading compared to outdated ones. OpenGLES.

However, the transition to Vulkan requires careful testing, since some old drivers or specific shaders may not work correctly. If your game uses complex post-effects or custom shaders, you may need to create separate assemblies for different APIs or implement a fallback mechanism. Optimization rendering directly affects the battery life of the device and its temperature.

An equally important parameter is the quality of textures and compression. In the section Quality Settings you can configure profiles for different device levels, automatically reducing shadow resolution and drawing distance on weak smartphones. Using a compression format ASTC instead of ETC2 allows you to reduce the size of the build and speed up the loading of textures into GPU memory, which is critical for games with rich graphics.

Parameter Recommendation for High-End Recommendation for Low-End Impact
Graphics API Vulkan OpenGLES 3.0 GPU performance
Texture Compression ASTC 6x6 ETC2 Memory and build size
Shadow Resolution 2048x2048 512x512 Shadow clarity and FPS
Anti-Aliasing 4x MSAA Disabled Anti-aliasing edges
๐Ÿ’ก

Use Unity quality profiles to automatically switch graphics settings depending on the user's device model. This will allow you to reach the widest possible audience without losing the comfort of the game.

Adaptation of controls and user interface

Transferring controls from the keyboard and mouse to the touch screen is not just a replacement of input, but a complete redesign of interaction with the game. Unity uses a Input Systemsystem for this, which allows you to abstract from a specific input device. You need to create control schemes where actions (jump, attack, move) are mapped to virtual buttons or gestures rather than to physical keys.

Interface development requires taking into account the variety of screens. The aspect ratio on modern smartphones varies from the classic 16:9 to the elongated 21:9. Using a component Canvas Scaler with mode Scale With Screen Size ensures that UI elements will be displayed correctly on any device. Critical buttons like Pause or Inventory should be within reach of your thumb.

It's also worth implementing multi-touch support, as players often use multiple fingers simultaneously to move the camera and character. A standard component TouchInputModule may not be sufficient for complex projects, so many studios write custom touch handlers for more precise control of input delays and priorities.

The problem of โ€œghost clicksโ€

On some cheap screens, the effect of false sensor triggers may occur. To combat this, implement joystick dead zones and fast repeat filtering in your input processing code.

Optimizing performance and memory

Optimizing for Android requires an aggressive approach to resource management. The main problem of mobile platforms is the limited amount of RAM and the lack of a page file. If your game consumes more memory than the system has available, the operating system will forcefully terminate the process. Using Profiler in connection mode to a device allows you to monitor peaks in memory consumption in real time and identify leaks.

Particular attention should be paid to garbage collection (Garbage Collection). Frequent allocation of objects in the heap during the game cycle causes micro-freezes, which are perceived much more painfully on a mobile device than on a PC. Try to avoid creating new objects inside a method Update, use object pools for bullets, enemies and effects, and use structs instead of classes where possible.

The battery is another limiting resource. Constant operation of the processor at maximum frequencies leads to throttling (a decrease in frequency due to overheating). Code optimization, reducing the number of draw calls through batching and disabling unnecessary calculations in the background help reduce heat dissipation. A game that does not overheat the phone has a much higher chance of getting high ratings in the store.

โš ๏ธ Attention: Optimization testing should be carried out on real devices in the middle and low price segment. Emulators and flagship smartphones of the developer do not show a real picture of performance among the mass audience.

๐Ÿ“Š At what stage of development do you start optimization?
From the very beginning of the project
When the game is 50% ready
Before release
Only if players complain

Building, signing and creating APK/AAB

When the project is configured and optimized, the build phase begins. In the window Build Settings you need to select the target Android platform and processor architecture. Today, the Google Play store requires support for 64-bit architecture ARM64, so make sure that the checkbox ARM64 is active in the list Target Architectures. Disabling the outdated ARMv7 can reduce the size of the build, but will deprive you of part of the audience with old phones.

For publication in the Google Play Console, the format Android App Bundle (.aab) instead of the old APKis now required. The AAB format allows the store to generate optimized APKs for each specific user device, including only the necessary resources and libraries. You can still use APK for local testing, but prepare only AAB for release.

The critical point is signing the application. You need to create Keystore (key storage) through the menu Player Settings โ†’ Publishing Settings. This file contains a cryptographic key that verifies the authorship of the application. Losing this file means you won't be able to update the game in the future, so keep it in a safe place and create backup copies.

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
๐Ÿ’ก

The Android App Bundle (AAB) format is a mandatory standard for publishing on Google Play, as it provides dynamic resource delivery and reduces the download size of the application for the user.

Error diagnosis and logging on the device

Even after a successful build, the game may crash or behave incorrectly on a real device. To debug, you need to connect your smartphone to your computer via USB and enable the โ€œUSB Debuggingโ€ mode in the developer settings on your phone. Unity allows you to connect to a running process through the menu Attach to Process in the code editor, which makes it possible to set breakpoints and analyze variables in real time.

If connecting through the editor is not possible, use the tool ADB (Android Debug Bridge). Console commands allow you to display system and application logs, monitor memory consumption, and even install builds without an interface. Filtering logs by tag Unity helps to separate engine messages from system noise of the operating system.

A frequent problem is the difference in the behavior of the game on different versions of Android. What works on Android 13 may fail on Android 10 due to changes in file access or permission policies. Keeping a detailed error log and sending data to the analytics server allows you to collect crash statistics from real users and promptly release patches.

โš ๏ธ Attention: Developer settings interfaces and debugging methods may differ depending on the smartphone manufacturer (Samsung, Xiaomi, Pixel). Always check the official documentation for the latest instructions for your specific device model.

Frequently asked questions (FAQ)

Why does my game crash immediately after launching on my phone?

The most common reason is a mismatch in the processor architecture or the lack of necessary native libraries. Check that the architecture ARM64is selected in the Player settings. Also make sure that all plugins have Android versions and do not conflict with each other. Check the logs via ADB to get the exact error code.

How to reduce the size of the final APK file?

Use a format Android App Bundlethat automatically removes unused resources for specific devices. In the texture import settings, enable compression and remove unused assets from the project. You can also disable support for older processor architectures if your target audience uses modern smartphones.

Do you need to buy a Unity license to publish on Android?

To publish free games or games with income below a certain threshold, the free version is enough Unity Personal. However, if your income exceeds the limits specified in the license agreement, you will need to switch to paid tariffs Pro or Enterprise. Always check the latest terms and conditions on the official Unity website.

Is it possible to test the game without a real Android device?

Yes, you can use emulators, such as Android Studio Emulator or third-party solutions like BlueStacks. However, emulators do not always accurately reproduce the behavior of the sensor, GPS, accelerometer and the actual load on the processor. Final testing must be carried out on physical devices.