Mobile game development is a complex process that begins long before the first line of code is written. A critical step The key is setting up the development environment correctly, especially when it comes to a cross-platform engine. Many beginners encounter difficulties at the very beginning, trying to understand how to correctly integrate the mobile platform into their work process. The choice of target device affects everything from the libraries used to graphics optimization methods.
When a developer wonders how to choose an android in Unity, he is actually interested in configuring Build Target and related modules. Errors at this stage can lead to incorrect operation of the application on real devices or the inability to even start compilation. Android SDK i Java Development Kit must be installed and associated with the engine accordingly. Without this step, creating a full-fledged APK file will become impossible.
In this article we will look at all the nuances of the configuration so that you can avoid common pitfalls. We will cover not only the technical aspects of the installation, but also the logical decisions that need to be made before starting the active development phase. Understanding the differences between operating system versions and processor architectures will allow you to create a product that will run reliably on millions of devices around the world.
Setting up Build Target and installing modules
The first step in the process is to switch platforms within the engine itself. By default, Unity may be configured to work with PC or WebGL, so you must manually enable support for mobile operating systems. To do this, go to menu File → Build Settings. In the window that opens, you will see a list of available platforms, where you need to find the robot logo and press the button Switch Platform. This process may take several minutes, as the engine will need to recompile some internal assets.
However, simply switching is not enough. The engine does not contain all the necessary tools for compiling for Android out of the box. You will need to install additional modules via Unity Hub. Go to the settings of your version of Unity, find the section Add Modules and make sure that items Android Build Support, Android SDK & NDK Tools and OpenJDKare selected. Using external versions of these tools often leads to path conflicts and compilation errors, so it is recommended to rely on built-in solutions.
After installing the modules, you need to check the paths to the tools in the global settings. Go to Edit → Preferences → External Tools. Here you will see fields for specifying paths to Android SDK, NDK and JDK. If the modules were installed via Hub, the paths should be determined automatically. Attention: If you see red warnings, communication with the tools has been lost and the build will fail. In this case, try pressing the button Validate or reinstalling the modules.
⚠️ Attention: The Unity Hub interface and the location of the External Tools settings may change with the release of new versions of the engine. Always check the official release notes if you cannot find the usual menu items.
Configuration of Player Settings and API versions
After successfully switching the platform, you will be faced with the question of choosing a specific version of the operating system. In the section Player Settings, which is located in the same Build Settings window, you need to find the parameter Minimum API Level. This value determines the oldest version of Android that your app can run on. Choosing a version that is too low (for example, Android 4.4) may expand your audience, but will deny you access to modern features and optimizations.
On the other hand, setting a high entry threshold will cut off owners of older devices. At the moment, Android 7.0 (API 24) or Android 8.0 (API 26)is considered a reasonable minimum. It is also important to pay attention to the parameter Target API Level. Google Play requires new apps and updates to target a specific API version or higher to ensure security and performance. Ignoring this requirement will lead to rejection when publishing.
- 📱 Minimum API Level: lower limit of compatibility, below which the application will not be installed.
- 🎯 Target API Level: version for which the application is optimized (usually the latest stable one).
- 🔒 Permissions: list of requested permissions, which is generated automatically based on the functions used.
It is also important to configure the package identifiers. The field Package Name must be unique and match the reverse domain name (for example, com.companyname.game). Changing this setting after publishing the application in the store is impossible without creating a new listing. Company Name and Product Name also affect the file structure and display on the system.
Use the prefix "dev" or "test" in the Package Name for debug builds (for example, com.company.game.dev) so that they do not conflict with the main version on device.
Choice of processor and graphics architecture
The modern market for Android devices is extremely fragmented not only by OS versions, but also by hardware. The key is to select the correct processor architecture in the settings Target Architectures. Historically, there was a division into ARMv7 (32-bit) and ARM64 (64-bit). Today, support for 64-bit applications is a mandatory requirement on Google Play for most new projects.
The choice of architecture directly affects the size of the final APK file. If you check both boxes (ARMv7 and ARM64), the file size may double, since the libraries will be compiled for both types of processors. However, this ensures maximum compatibility. For heavy projects, they often use App Bundles (.aab)which allow the store to automatically download to the user only that part of the code that is needed for his specific device.
| Architecture | Type | Support status | Recommendation |
|---|---|---|---|
| ARMv7 | 32-bit | Outdated | Keep only for legacy projects |
| ARM64 | 64-bit | Standard | Required for all new projects |
| x86 | 32-bit | Rarity | Only for emulators |
| x86_64 | 64-bit | Emulators/Tablets | Optional, increases size |
It is also worth touching on the topic of graphics APIs. Unity by default uses Vulkan or OpenGLES depending on the device. In the settings Other Settings you can force the preferred API to be selected. Vulkan Provides better performance and graphics quality on modern chips, but may be unstable on very old models. OpenGLES 3.0 Remains the safest choice for maximum compatibility.
For publication on Google Play today Support for 64-bit architecture (ARM64) is required, otherwise the application will not pass moderation.
Optimization for various devices
Choosing Android in Unity is not only a technical setup, but also a strategic decision about which devices you want to reach. The variety of screens, aspect ratios and pixel densities (DPI) requires a special approach. In the Resolution and Presentation player settings section you can set scaling parameters. It is recommended to use mode Scale To Fit or customize Safe Areato prevent the interface from being cut off on screens with notches or rounded corners.
Device memory is another critical resource. Mobile devices have limited RAM compared to PCs. Excessive use of high-resolution textures or complex shaders can lead to application crashes (Crash on Start). Use profiling tools such as Unity Profiler and Memory Profilerby connecting a real device via USB. This will allow you to see how the game behaves in real conditions, and not just in the editor.
- 🖼️ Texture Compression: Choose ASTC for modern devices, this is the best balance of quality and size.
- ⚡ Stripping Level: Enable IL2CPP and a high level of stripping to reduce code size.
- 📉 Quality Settings: Create several quality profiles for different classes of devices (Low, Medium, High).
- 📦 Asset Bundles: unload heavy resources dynamically to avoid APK bloat.
Don't forget about thermal throttling. Powerful processors in phones quickly heat up, after which the system artificially lowers the frequencies, and the game begins to slow down. Optimizing the code and reducing the load on the GPU will help maintain stable FPS longer. Using IL2CPP instead of a Mono script backend is the standard for release builds for Android as this gives a performance boost and protects the source code from easy disassembly.
⚠️ Warning: Graphics and quality settings that work great on a Samsung or Xiaomi flagship may completely stop the game on a budget device. Always test on a “weak” device.
Application signing and security
The final stage of preparation for release is digital signing. Android requires every APK or AAB file to be signed with a cryptographic key. This confirms authorship and ensures that the application has not been modified by third parties after it has been built. In Unity, this process is automated, but requires creation Keystore. This is a file with the extension .keystore or .jksthat contains your.private keys.
When you first build, Unity will prompt you to create a new Keystore or use an existing one. Extremely important save this file and passwords in a safe place. Losing the key means it is impossible to update the application in the store - you will have to publish it as new, with all the ensuing consequences (loss of reviews, ratings and installed users). The password must be complex, but memorable, since it is technically impossible to recover it.
What happens if you lose Keystore?
It will be impossible to restore access to updating the application. You will have to create a new project in Google Play Console, change the Package Name and start recruiting your audience all over again. Old users will not receive the update automatically.
In settings Publishing Settings you can enable the option Custom Keystoreif you work in a team or use corporate keys. The application version is also configured here (Version and Build). The version number (1.0) is visible to the user, and the build number (1, 2, 10) should be an integer and increase with each new upload to the developer console. Google Play will not accept a file with a build number lower than that already downloaded.
Debugging and logging on a real device
Emulators in Unity work well, but they cannot replace testing on real hardware. To connect the device, you must enable the mode on your phone USB Debugging. This item is hidden in the “For Developers” menu, which is activated after clicking on the build number seven times in the phone settings. After connecting the cable and confirming access on the smartphone screen, the device will appear in the list of available ones in Unity.
To view logs in real time, use the window Window → General → Device Manager (in new versions) or the standard Android Logcatbuilt into Unity. Filtering logs by tag Unity allows you to track script errors, problems with loading assets and the operation of native plugins. Logcat is the main diagnostic tool, without which searching for the causes of a crash can turn into torture.
☑️ Checklist before the first assembly
Situations often arise when the game works in the editor, but crashes immediately after launching on the phone. Most often this is due to lack of permissions (camera, geolocation) or incompatibility of native libraries. Carefully study the logs at the time of the crash - the exact reason will be indicated there (Exception, NullReference etc.). It is also useful to use remote debugging through Visual Studio, connecting to the process on the device via network or USB.
How to enable developer mode on Android?
Go to Settings → About phone → Tap 7 times on “Build number”. Then the “For Developers” item will appear in the settings menu, where you need to activate “USB Debugging”.
Why doesn’t Unity see my device?
Check the USB cable (it must support data transfer, not just charging), install the ADB drivers for your phone model and make sure that debugging permission is confirmed on the phone screen.
What is AAB and why is it better than APK?
Android App Bundle (.aab) is a publishing format that allows Google Play to dynamically generate an APK for a specific user device, reducing download size and saving space.