Developing a mobile application is only half the success, because the final stage is compiling the project into an installation file. The process of transferring a game from the development environment Unity to the platform Android may seem complicated to a beginner, but in fact it is strictly structured. Correctly setting the build parameters ensures that the game will launch on the smartphone without critical errors and will consume the optimal amount of resources.
In this article we will analyze in detail all stages of preparation: from installing the necessary modules in Unity Hub to signing the final build. You'll learn how to avoid common dependency mistakes and how to adjust graphics settings for different devices. High-quality export is the key to a positive user experience when you first launch your product in the app store.
Preparing the environment and installing modules
Before you try to build the project, you need to make sure that your installation Unity Editor supports the target platform. By default, when installing the engine, the module for Android is not activated, so you need to add it manually via Unity Hub. This is a critical step, without which the build button will be inactive or will show a missing tools error.
Open Unity Hub, go to the section Installs and click on the gear next to your version of the editor. In the list that appears Modules find the item Android Build Support. When you select this component, the system will automatically offer to install the accompanying tools: OpenJDK, Android SDK and Android NDK. Do not uncheck these additional items, as they are required to compile code and work with native libraries.
After installation is complete, restart the editor. Now an icon File โ Build Settings in the list of platforms. If it is not there, it means that the installation was incorrect, and the procedure should be repeated, making sure there is free space on the disk. The absence of at least one of the three components (SDK, NDK, JDK) will make it impossible to create a working application file. Androidshould appear in the menu
Make sure that the paths to JDK, SDK and NDK do not contain Cyrillic characters or spaces, as this is a common cause of failures when building on Windows.
Configuring project settings (Player Settings)
Switching the platform to Android in the window Build Settings, click the button Player Settings. An inspector panel will open, where all the key parameters of your future application are concentrated. First of all, pay attention to the section Other Settings, where the field Package Nameis located. This is a unique identifier for your application in the format com.name.gamewhich cannot be changed after publication on Google Play.
Next you need to select the processor architecture. In the section Configuration find the item Target Architectures. For maximum compatibility with old and new devices, it is recommended to check both options: ARMv7 and ARM64. However, please note that support for only 64-bit architecture (ARM64) is becoming a mandatory requirement for many new application stores, so it should be given priority.
It is also important to configure the API level in this section. The parameter Minimum API Level determines which versions of Android your game can run on. Setting the value Android 7.0 'Nougat' (API level 24) or higher is a modern standard that allows you to cover the majority of active devices, but cuts off outdated models that still will not support modern graphics.
A unique Package Name and the correct ARM64 architecture are the foundation for publishing an application in modern stores.
Optimizing graphics and resources
Mobile devices have limited resources compared to PCs, so export requires careful optimization of assets. In the player settings, find the section Graphics API. By default Unity can use Vulkan, which provides high performance, but may cause artifacts on some older devices. For wide compatibility, they often use OpenGLES3, which is the golden mean between quality and support.
Pay special attention to texture compression. In the window Build Settings in the block Compression Method select the method that matches your goals. To reduce the file size, use LZ4 or LZ4HC, which provide faster unpacking and lighter build weight. If the priority is the speed of loading levels, you can choose standard compression, but this will increase the final APK size.
| Parameter | Recommended value | Impact on the project |
|---|---|---|
| Color Space | Linear | Correct lighting and shadows |
| Scripting Backend | IL2CPP | Performance and code protection |
| Target Architectures | ARM64 | Compatibility with new devices |
| Strip Engine Code | Enabled | Reducing file size |
Using a backend IL2CPP instead Mono has become an industry standard. This method converts C# code to C++, which significantly speeds up script execution on mobile processors and makes reverse engineering your game more difficult. The only negative is that the compilation time increases, but the result is worth the time spent.
Build process and APK creation
When all settings are checked, return to the window Build Settings. Make sure that all the necessary scenes are added to the list Scenes In Buildotherwise the game will start on a black screen. Press the button Build to create a debug version or Build And Runif a device is connected to the computer via USB and debugging is enabled.
In the window that appears, select an empty folder to save files and set a name. Unity will begin the compilation process, which can take from several minutes to an hour depending on the complexity of the project and the power of the computer. At this time, it is not recommended to run other heavy applications so as not to interrupt the memory allocation process.
โ๏ธ Ready for assembly
After the process is completed, in the specified folder you will find a file with the extension .apk. This is an installation package that can be transferred to your smartphone for testing. If you plan to publish to the Google Play Console, you will need to create not an APK, but Android App Bundle (.aab), for which you need to check the box Export Project or select the appropriate option in new versions of the engine when exporting.
โ ๏ธ Attention: Never publish debug versions (Debug) in the store, compiled without signature with the developer key. Such applications have reduced performance and may be rejected by moderation.
Signing the application (Keystore)
To install the application on any device except developer mode, and especially for publishing it on the store, the file must be signed with a digital certificate. In Unity this process is configured in section Player Settings โ Publishing Settings. Here you need to create a new one Keystore or use an existing one.
When creating a new keystore, you will be asked to create a password and fill in the owner data (Alias, Organization). Save the .keystore file and remember the passwords in a safe place, since without them you will never be able to update your application in the store. Losing the key means you have to publish the game as a completely new product with a different package name.
After setting the path to the store file and entering the passwords in the Keystore Pass and Key Passfields, the check mark Custom Keystore will become active. Now, when you click the Build button, Unity will automatically sign the resulting file. This is a mandatory security requirement of the Android platform, guaranteeing the authorship of the update.
What to do if you forgot your Keystore password?
It is technically impossible to recover the keystore password. You will have to create a new Keystore, change the Package Name of the game and upload it to the store as a new application, losing all previous users and reviews.
Typical errors and how to solve them
The export process rarely goes perfectly the first time, especially in complex projects. One of the most common problems is error Gradle build failed. It is often associated with incompatibility of versions Android SDK and settings in the file build.gradle. Check that Player Settings has the current version installed Target SDK Versionthat meets the requirements of Google Play.
Another common problem is the application crashing immediately after launch (Crash on start). This could be caused by missing required permissions in the manifest or by trying to use features that are not supported on the device. Enable logging via adb logcat to view the cause of the failure in real time. Also make sure that all plugins you use are versions compatible with your version Unity.
โ ๏ธ Attention: The Unity interface and Google Play requirements are updated regularly. Always check the latest requirements for the Target SDK version in the developer documentation before the final build.
If the application size exceeds the store limits (150 MB for APK), use the system Asset Bundles to load resources over the network or switch to the format Android App Bundle, which automatically compresses resources for a specific user device. This allows you to significantly reduce the weight of the downloaded file.
Frequently asked questions (FAQ)
Is it possible to test the game without building an APK?
Yes, you can use the function Build And Runby connecting your smartphone via USB with debugging enabled. There is also the option of remote debugging over Wi-Fi using the app Unity Remotealthough it only transmits the image and input and the rendering happens on the PC.
What is the difference between APK and AAB?
APK is a device-specific installation file containing all the resources. AAB (Android App Bundle) is a publishing format for Google Play that allows the store to generate optimized APKs for each type of device, saving space for the user.
Why does the game slow down on the phone, but flies in the editor?
Mobile processors have limitations in heat output and frequency. Most likely, you have not optimized the number of polygons, have not adjusted the levels of detail (LOD), or are using heavy shaders that are not adapted for mobile GPUs.
How to reduce the size of the final file?
Use ASTC texture compression, disable unused engine modules in the build settings, remove unnecessary scenes and apply tool Strip Engine Code for removing unnecessary code Unity.