The Android platform opens up enormous opportunities for independent developers, allowing them to bring their creations to billions of users around the world. Creating an interactive application from scratch requires not only creativity, but also a clear understanding of the technical stack, which includes the game engine, compilation tools and the specifics of the mobile operating system. Unity 3D is deservedly considered the industry standard in this area, providing a powerful set of visualization, physics and scripting tools necessary to implement any ideas.

The process of transferring a project from a personal computer to a mobile device involves a number of specific tasks, such as optimizing performance, adapting controls to a touch screen, and correctly setting access rights. Mistakes during the project configuration phase can result in the application simply not running on the target device or consuming an excessive amount of battery resources. In this guide, we will analyze in detail each stage of the path from creating an empty project to assembling a ready-made installation file.

Preparing the development environment and installing modules

The first critical step is to correctly install the engine itself Unity Hub and select the appropriate version of the editor. To work with mobile platforms, it is not enough to install only a basic editor; You must additionally activate the Android Build Support module during the installation process or through the settings of an already installed product. This module includes the necessary libraries, emulators and debugging tools, without which compilation for the ARM architecture is impossible.

After installing the engine, you will need to configure external dependencies, since Unity relies on third-party software to final build the package. The key components here are Android SDK (Software Development Kit) and JDK (Java Development Kit). Modern versions of Unity often offer to install the recommended versions of these components automatically, which greatly simplifies the process for beginners and reduces the risk of version conflicts.

In the editor settings, accessible through the menu Edit โ†’ Preferences โ†’ External Tools, you must explicitly specify the paths to the installed components if they were not detected automatically. Incorrect path location to Android SDK or JDK is one of the most common causes of compilation errors, which appear as red messages in the console when trying to build.

โš ๏ธ Attention: JDK versions must be strictly compatible with the version of your Unity Editor. Using a too new or, conversely, outdated version of Java may result in Gradle being unable to build the project. Always check the requirements in the official Unity documentation for your specific version of the editor.

Project setup and platform switching

After creating a new project or opening an existing one, the first action you need to perform is switching the target platform. By default, Unity is configured to work with PCs (Windows, Mac or Linux), so unless explicitly specified, the engine will not take into account the limitations and features of mobile hardware. To do this, open a window File โ†’ Build Settings and select Androidin the list of platforms, then press the button Switch Platform.

The switching process can take from several minutes to half an hour, since the engine needs to recompile assets and shaders for the new architecture. At this moment, textures are converted into a format optimal for mobile GPUs, usually ASTC or ETC2 compression, which is critical for saving device video memory. It is not recommended to interrupt this process, as this may damage temporary library cache files.

After a successful switch, Android-specific options become available in the same build settings window. Here you need to select Target SDK and Minimum API Level. Choosing the minimum API level determines which older versions of Android your game can run on, but setting it too low can limit access to modern system features and require checks in the code.

๐Ÿ“Š What genre of game are you planning to develop?
Hypercasual Arcade
3D Shooter
Open world RPG
Puzzle
Strategy

For the correct operation of modern Google Play services and access to new Android functions, the Target SDK level must meet the current requirements of the application store. If you are planning to publish on Google Play, ignoring this requirement will result in the build being rejected when uploaded to the developer console.

Optimizing graphics and performance

Mobile devices, despite the rapid growth in their power, still have strict limitations on heat generation and energy consumption compared to desktop systems. A key aspect of development is optimizing the number of draw calls (Draw Calls), since each extra call loads the processor. Use batching techniques (static and dynamic batching), combining objects with the same materials to reduce the load on the graphics pipeline.

Textures take up a significant portion of RAM, so their size and compression format require special attention. In the Texture Inspector, set the maximum size to match the pixel density of the target devices' screens, avoiding using 4K textures for mobile phones unless absolutely necessary. Using texture atlases allows you to pack many small images into one large map, further reducing the number of texture switches during rendering.

Lighting (lighting) in mobile games often requires trade-offs between quality and performance. Dynamic lighting in real time is extremely expensive, so it is recommended to pre-bake the light (Baked Lighting) into lighting textures for static objects. This allows you to get a high-quality picture with shadows and global illumination without loading the processor during a gaming session.
๐Ÿ’ก

Use the Unity Profiler in "Deep Profile" mode on a real device rather than an emulator to get accurate data on rendering latency and memory usage. Emulators often distort performance indicators.

The table below shows the recommended graphics quality settings for various classes of devices:

Quality level Shadow resolution Anti-aliasing Target devices
Low 256x256 Disabled Budget smartphones
Medium 512x512 2x MSAA Middle segment
High (High) 1024x1024 4x MSAA Flagship models
Ultra (Ultra) 2048x2048 8x MSAA Gaming smartphones

Implementation of touch control and input

The transition from a keyboard and mouse to a touch screen radically changes the paradigm of player interaction with the interface. Unity uses the Input System or the outdated but still popular system Input.GetAxis in conjunction with multi-touch event processing to handle touches. It is important to provide for various input scenarios: single taps, swipes, multi-touch to control the camera or perform actions simultaneously.

To implement virtual joysticks and buttons on the screen, you need to create a UI canvas and place the corresponding controls on it, linking them to event processing scripts. At the same time, it is critical to take into account different screen diagonals and aspect ratios, using components Canvas Scaler and anchors (Anchors) for the correct positioning of interface elements. Buttons should not overlap important gameplay elements and should be large enough for comfortable finger pressing.

โš ๏ธ Attention: Don't forget to add support for different screen orientations (Portrait/Landscape) in the project settings if required by game design. Fixing the orientation rigidly may be necessary for some genres, but limits the audience.

Input processing logic should be abstracted from a specific device so that you can easily test the game on both PC and mobile. Create a single input interface that returns motion vectors regardless of whether the WASD key is pressed or a finger touches the virtual joystick. This will simplify debugging and allow you to quickly switch between platforms during development.

โ˜‘๏ธ Check the input system

Done: 0 / 4

Build configuration and application signing

The final stage of preparation for testing or publication is setting the build parameters in the window Build Settings. One of the most important parameters is Package Name, which is a unique identifier for your application in reverse domain format (for example, com.companyname.gamename). It will not be possible to change this setting once the application is published in the store, so choose it wisely.

To install the application on a real device or upload it to the Google Play store, the file must be digitally signed. Unity allows you to create a new signing key (Keystore) directly in the player settings window (Player Settings โ†’ Publishing Settings). You will need to set a password for the keystore and a password for the key itself, as well as fill out information about the alias.

Never lose the Keystore file and do not forget the passwords for it, since without them you will not be able to release updates for an already published application. Losing the signature key means having to publish the game as a completely new project with a new package name, losing all old users and reviews.

The output file format can be chosen as APK (for direct installation and debugging) or AAB (Android App Bundle). Google Play currently requires the AAB format for new publications, as it allows the store to automatically generate optimized APKs for specific user device configurations, reducing the download size.

Difference between APK and AAB

APK is a ready-made installation package that contains all the resources for all configurations, which makes it heavier. AAB is an archive that Google Play uses to generate lightweight APKs specifically for the user's phone model, saving its traffic and space.

Debugging and testing on a real device

Testing in the Unity editor cannot completely replace testing on real hardware, since emulators do not accurately reproduce the behavior of sensors, real FPS indicators and the specifics of working with mobile memory chips. To connect the device, turn on the "For Developers" mode on your smartphone and activate USB debugging. Connect your phone to your computer with a cable and wait until Unity detects it in the list of available devices to run.

If Runtime Errors occur, use the window Console and Android Logcat logs, which can be viewed directly inside Unity or through third-party utilities like Android Studio. Logs contain critical information about crashes, memory leaks and problems loading assets that are often not visible during normal startup.

Remote Unity Profiler allows you to connect to an application running on your phone and see real-time performance graphs on your computer. This is an indispensable tool for finding bottlenecks, whether it's overloading the processor with scripts or overloading video memory with textures. Analyze peaks in graphs and correlate them with in-game actions to find the cause of lags.
๐Ÿ’ก

Testing on a wide range of devices (different versions of Android, different manufacturers) is mandatory, since the fragmentation of the Android ecosystem can reveal bugs that do not appear on your personal smartphone.

Frequently asked questions (FAQ)

Do I need to pay to use Unity for Android development?

The basic version of Unity Personal is free for use by individuals and companies with annual income below a certain threshold (the amount is regularly indexed). For commercial development with large incomes, a Pro or Enterprise subscription is required, but the very fact of publishing for Android does not require additional license fees beyond the terms of the subscription.

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

The most common reasons: non-compliance with the minimum Android API version, lack of necessary permissions in the manifest, use of native plugins incompatible with the processor architecture devices (ARM64 vs ARMv7), or a critical error in the code during initialization. Check the Logcat logs for the exact error message.

How to reduce the size of a game's APK file?

Use AAB format instead of APK, enable code compression (ProGuard or IL2CPP with stripping), optimize textures (reduce resolution, use ASTC compression), remove unused assets and consider loading heavy content on demand (Asset Bundles) instead of including it in the main build.

Is it possible to test the game without connecting a cable?

Yes, you can collect an APK file, transfer it to your phone via the cloud or messenger and install it manually. However, for real-time debugging, viewing logs and using the profiler, a USB connection or Wi-Fi debugging (if ADB is configured correctly) are required.