Developing a mobile application is an exciting process that opens access to a huge audience of users Android. Unity is one of the most popular engines for this task, allowing you to create both complex 3D games and interactive 2D applications with minimal time. The cross-platform nature of the engine allows you to write code once, and then adapt it to different screen resolutions and hardware configurations. However, the path from an empty project to a ready-made file requires a clear understanding of the engine settings and operating system requirements. You have to set up the environment, optimize graphics for mobile processors and properly configure screen output. In this article, we will analyze all the key steps that will turn your prototype into a full-fledged application, ready for installation on a smartphone.
However, the path from an empty project to a finished one .apk or .aab file requires a clear understanding of the engine settings and operating system requirements. You have to set up the environment, optimize graphics for mobile processors and properly configure screen output. In this article, we will go over all the key steps that will turn your prototype into a full-fledged application, ready to be installed on your smartphone.
Preparing the environment and setting up modules
The first step before starting work is to install the necessary components via Unity Hub. The standard installation of the engine is not enough, since compilation for Android requires additional support modules. In the window for installing Unity versions (Installations), you must click the "Add modules" button and select Android Build Support.
Together with the main module, be sure to install Android SDK & NDK Tools and OpenJDK. These components are critical for compiling Dalvik/ART code and working with native libraries. Without them, the build button will be unavailable, and the engine will generate errors when trying to switch platforms.
โ๏ธ Checking the installation of modules
After installing the components, you should check the paths to the SDK and NDK in the editor settings. Go to menu Edit โ Preferences โ External Tools. Make sure that the Android SDK Path and NDK Path fields contain the correct directories. If you installed modules through Unity Hub, the paths should be filled in automatically.
โ ๏ธ Attention: Versions NDK must be compatible with the version of your Unity Editor. Using a version of the NDK that is too new or too old can lead to errors in linking native libraries when building the project.
Setting up a project for a mobile platform
After preparing the environment, you need to switch the target platform of the project. Open the window File โ Build Settings and select Androidin the list of platforms. Click the button Switch Platform. This process may take some time as the engine recompiles assets for the new architecture.
The key setting element is the section Player Settings, accessible through the button in the Build Settings window or through the menu Edit โ Project Settings โ Player. Here is a tab Android, where the basic parameters of the application are set. In the Package Name field, enter a unique identifier, for example, com.companyname.productname. This identifier cannot be changed after the application is published on Google Play.
Pay special attention to the graphics settings. In the Graphics APIs section, Vulkan and OpenGL ES can be selected by default. For maximum compatibility with older devices, it is recommended to leave OpenGLES3, however, for new projects with advanced graphics it is better to use Vulkan. It is also important to install the minimum version of the API (Minimum API Level) that meets the requirements of your target devices, usually Android 7.0 (API Level 24) or higher.
Optimizing textures for Android
In the texture import settings, be sure to enable ASTC compression for modern devices and ETC2 for older devices. This will significantly reduce the size of the final file and RAM consumption, which is critical for mobile GPUs.
Don't forget to adjust the screen orientation in the section Resolution and Presentation. Suitable for most games and utilities: Portrait (portrait) or Landscape (landscape). If your application supports rotation, select Landscape Left and Right or Portrait Upside Down depending on the interface logic.
Interface adaptation and control
Mobile devices have a fundamentally different way of interacting with the user compared to PCs. The lack of a physical keyboard and mouse requires the use of touch input. In Unity, the component Input System or classic Input Manageris responsible for this. You need to handle touches (Input.GetTouch) instead of mouse clicks.
The user interface (UI) must adapt to different screen aspect ratios. Using the component Canvas Scaler with mode Scale With Screen Size will allow interface elements to be displayed correctly on both narrow smartphones and wide tablets. Reference Resolution is usually set to 1920ร1080 or 2340ร1080.
- ๐ฑ Use safe zones (Safe Area) so that the interface is not blocked by camera cutouts or Android system elements.
- ๐๏ธ Make buttons with interactive elements large enough (minimum 48x48 pixels of screen density) for comfortable finger pressing.
- ๐ Implement multi-touch support if the mechanics of the application require the simultaneous use of several fingers.
It is important to consider the variety of screens with high pixel density (DPI). Fonts and vector graphics should remain crisp on 2K and 4K resolution screens. For text fields, use TextMeshProwhich provides better font rendering quality compared to the standard Text component.
Optimizing performance and size
Mobile devices are limited in battery, memory and processing power. Optimization is not just a recommendation, but a necessity. The first step is to analyze the scene using the built-in profiler. Go to Window โ Analysis โ Profiler and run the application on the connected device to find bottlenecks.
The build format has a significant impact on the size of the final file. In settings Build Settings select architecture ARM64as modern application stores require 64-bit applications. It is also recommended to use the assembly format Android App Bundle (.aab) instead of .apk. The AAB format allows Google Play to generate and serve to the user only those resources that are needed specifically for his device, which reduces the download size.
To reduce energy consumption and processor heating, limit the frame rate (Target Frame Rate) in the application code. For most mobile games, 60 FPSis enough, and for some genres (for example, turn-based strategies), you can set a limit of 30 FPS. This will significantly extend battery life.
โ ๏ธ Attention: Google Play's APK file size requirements are strictly regulated (maximum 150 MB for a basic download). If your project exceeds this limit, use Asset Bundles or Play Asset Delivery to load heavy resources over the network.
Build process and debugging on the device
To run the application on a real device, you must enable debugging mode on your smartphone. Go to Settings โ About phone and click on the build number seven times to activate the developer menu. Then in the menu that appears For developers turn on the item USB debugging.
Connect the device to the computer via a USB cable. In Unity, your smartphone should appear in the list of devices to launch (Run Device). If the device is not detected, check the installed ADB drivers. To start, use the button Build And Run in the Build Settings window.
The debugging process includes real-time monitoring of logs. The window Window โ General โ Device and Logcat allows you to see Android system messages and your application logs. Filter logs by tag Unity or yours Package Nameto track errors.
| Build parameter | Recommended value | Impact |
|---|---|---|
| Scripting Backend | IL2CPP | Improves code performance and security |
| Target Architectures | ARM64 | Required for publication on Google Play |
| Strip Engine Code | High | Reduces file size by removing unused code |
| Compression Method | LZ4 | Balance between loading speed and size |
App signing and publication
The final stage before publication is the digital signing of the application. Android requires every APK or AAB file to be signed with a developer key. In Unity, this is configured in the Player Settings โ Publishing Settingssection. You need to create a new Keystore or select an existing one.
Keystore is a file with the extension .keystore or .jksthat contains cryptographic keys. Never lose this file and its passwords! Without this key, you will not be able to release an update for your application, since the signatures must match. Save a backup copy of the key in a safe place.
Save the Keystore file and passwords in cloud storage and on physical media. Losing the signing key means that you will not be able to update the application on Google Play, which will require creating a new project from scratch.
After setting up the signature and successfully building the release version (Build Type: Release), the file is ready to be uploaded to the Google Play Console. Before publishing, make sure that you have read the security policy and store content requirements.
โ ๏ธ Attention: Google Play has changed its security policy. New apps must now target the latest Android APIs. Always check the latest requirements in the developer console before the final build, as rules may change.
Development Frequently Asked Questions (FAQ)
Why can't Unity see my Android device?
Check if USB debugging is enabled in the developer settings on your phone. Make sure you have the correct ADB driver installed for your phone model. Try replacing the USB cable, as some cables only support charging.
What is the minimum font size to use for a mobile UI?
It is recommended to use fonts of at least 14-16 sp (scale-independent pixels) for body text. For important buttons and headings, the size should be even larger to ensure readability on small screens without compromising the user's vision.
Is it possible to create an Android application without Unity programming?
Yes, using visual programming (for example, Bolt or Playmaker) or ready-made assets from the Asset Store, you can create a simple application. However, for complex logic and optimization, knowledge of C# is still required.
How to reduce the size of the final APK file?
Use texture compression (ASTC/ETC2), remove unused assets, enable the Strip Engine Code option and use the Android App Bundle (.aab) format instead of the APK. Also check the size of the built-in libraries.
Successful publication of an application in Unity depends not only on the code, but also on the correct configuration of Player Settings, optimization for mobile hardware and compliance with Google Play requirements for signing and file formats.