Transferring a game project created in the engine Unityto the platform Android is a critical step for any indie developer or studio wanting to reach a mobile audience. This process does not come down to simply changing the target platform in the settings; it requires a deep redesign of the control architecture, optimization of the graphics pipeline and adaptation to thousands of different device configurations. The mobile market dictates its own strict rules: limited battery resources, the absence of a physical keyboard and the need for instant loading.
In this article we will analyze in detail the entire project preparation cycle. You will learn how to configure Build Settingscorrectly, which settings Player Settings affect performance the most, and how to avoid common errors that cause the application to crash on startup. Porting is not magic, but a strict sequence of technical actions, each of which matters for the final quality of the product.
Are you ready to turn your PC prototype into a mobile store hit? Let's start with the fundamental environment settings, without which further work is impossible. The success of the project often depends on how competently this preliminary preparation was carried out.
Preparing the environment and setting up the SDK
Before pressing the button Build, you need to make sure that your Unity editor โseesโ the Android development tools. This is the base, without which the assembly simply will not start. You will need to install Android SDK, JDK (Java Development Kit) and NDK (Native Development Kit). Modern versions of Unity often offer to install them automatically via Unity Hubwhich makes life much easier for beginners.
However, automatic installation does not always go smoothly. Sometimes you need to manually specify paths to tools in the editor settings. Go to menu Edit โ Preferences โ External Tools. Here you will see fields for specifying paths. If you are using a standard installation via Hub, the checkboxes opposite items Android SDK Tools and OpenJDK should be active.
Pay special attention to the version NDK. Building native plugins or using certain libraries may require a specific version of the toolkit. Version mismatches often lead to compilation errors that are difficult to debug without logging.
- ๐ Check environment variables
ANDROID_HOMEandJAVA_HOMEin the system if the build crashes with a path error. - ๐ Make sure that the test device is enabled mode USB debugging in the developer menu.
- โ๏ธ In the Unity settings, select
Android Build Supportwhen installing the editor, if this module is missing.
โ ๏ธ Attention: The paths to the SDK and JDK folders should not contain Cyrillic characters or spaces. This is a common cause of build failures on Windows. Use only the Latin alphabet and short paths, for example
C:\Android\SDK.
Configuration of Player Settings and graphics
After connecting the modules, we move on to the settings of the project itself. In the window Build Settings select the platform Android and click Switch Platform. This process may take time as the engine recompiles assets for the new architecture. Immediately after the switch, open Player Settings, where the most important optimization levers are hidden.
In the section Other Settings find the item Package Name. This is your app's unique identifier (for example com.studio.mygame) and cannot be changed once it is published to Google Play. Also configured here Minimum API Level. Setting a value too high will weed out users with older phones, while setting it too low will deny access to modern system features.
The graphical backend plays a crucial role in performance. By default, Unity may use OpenGL ES 3.0, but for a wide range of devices it is often recommended to Vulkan or OpenGLES 2.0 for maximum compatibility. Experiment with these settings by measuring FPS on target devices. Don't forget to disable unused modules in the Strip Engine Codesection to reduce the build size.
Enable the "Auto Graphics API" option only in the early stages of development. For release, it is better to manually select the desired API (for example, Vulkan) to avoid unexpected artifacts on specific MediaTek or Adreno chips.
Pay special attention to rendering resolution. Mobile screens have a high pixel density, and rendering at native resolution can kill your battery in an hour. Using scale Resolution Scaling Fixed DPI or forcing rendering resolution down to 720p or 900p often gives a 30-40% performance boost with virtually no visual loss of quality on small screens.
| Parameter | Recommended value | Impact |
|---|---|---|
| Color Space | Linear | Correct lighting and shadows |
| Scripting Backend | IL2CPP | Performance and code protection |
| Target Architectures | ARM64 | Google Play requirement from 2023 |
| Stripping Level | High | Reducing APK size |
Adaptation of controls and interface
The biggest pain when porting is management. The PC gamer is accustomed to the precision of a mouse and the tactile feedback of a keyboard. There's no physical feedback on the touchscreen, and your finger blocks part of your view. You will have to completely rework the input system, replacing events OnMouseDown with processing Input.touches or using a new system Input System from Unity.
The interface (UI) also requires adaptation. What looks good on a 24-inch monitor will be unreadable on a smartphone. Use the component Canvas Scaler with mode Scale With Screen Size. This will allow the interface to automatically adjust to different screen resolutions, from compact phones to tablets.
Don't forget about virtual joysticks and buttons. They should be large enough to be hit, but not take up half the screen. It is considered good form to be able to customize the location of controls in the game settings. This increases the accessibility of the project for people with different anatomical features of the hands.
- ๐ Implement multi-touch correctly: the player should be able to move and shoot at the same time.
- ๐ฑ Take into account the notch and camera cutouts in modern smartphones when designing the UI.
- ๐ Add gyroscope support for shooters or racing games as an alternative to touch controls.
โ ๏ธ Attention: Don't rely only on the emulator in Unity Editor. Touch input on a PC is simulated by a mouse and does not convey pressure or multi-touch gestures. Test controls only on a real device.
The secret of a comfortable joystick
Use dynamic joysticks that appear where the player touches the screen, and not at a fixed point. This allows you to control your character without looking at the buttons or blocking your view with your fingers.
Optimizing performance and memory
Mobile devices, despite progress, are still very limited compared to PCs. The main problem is heat generation and throttling. If your game loads the CPU at 100% for a minute, the phone will heat up and throttle down, resulting in a drop in FPS. Optimization should be proactive.
Start by analyzing the scene through Profiler. Look for bottlenecks: heavy shaders, excessive draw calls or memory leaks. For mobile platforms, it is critical to use Object Pooling (object pooling) instead of constantly creating and destroying prefabs during the game. This reduces the load on the Garbage Collector, which causes micro-freezes.
Textures are the main consumer of video memory. Compress them to ASTCformat, which provides better quality in a smaller size compared to DXT or ETC2. Reduce the maximum texture size to 1024x1024 or 2048x2048 for mobile devices. There is no point in loading 4K textures on a 6-inch screen.
Highlights and shadows should also be optimized. Avoid dynamic shadows from a large number of light sources. Use baked light (Lightmapping) for static objects. This transfers lighting calculations to the assembly stage, unloading the device's processor during the game.
The golden rule of mobile optimization: stable 30 FPS with good quality is better than jumping from 15 to 60 FPS with ultra settings. Smoothness is more important than the picture.
Working with resolutions and screen aspect
The fragmentation of the Android market is enormous. You'll encounter screens ranging from the old 4:3 to ultra-wide 21:9. If the camera is not adjusted correctly, the player will see a stretched picture or black bars on the sides. The main solution is to adjust the field of view (Field of View) and camera proportions.
Use Camera.rect or special assets to adapt the UI so that important interface elements do not fall into the โsafe zonesโ of screen cutouts. The game logic should not depend on a fixed resolution. All calculations of distances and hits must be carried out in world coordinates, and not in screen pixels.
For 2D games, set Pixel Perfect Cameraif you are using pixel art. This will prevent sprites from blurring when scaled on screens with non-standard pixel densities. For 3D games, it is important to check that important elements of the level are not cut off when changing the_aspect ratio_.
โ ๏ธ Attention: Test the game on devices with an aspect ratio of 18:9 and higher. It often happens that on such screens the camera shows too much sky or land, breaking the level design idea.
โ๏ธ Checklist before assembling the APK
Building, signing and publishing
The final stage is creating an installation file. Today, the de facto standard is the .AAB (Android App Bundle) format, and not the good old .APK. Google Play requires AAB to automatically optimize the size of the application for a specific user device when downloading.
To sign the application you will need Keystore. This is a file with cryptographic keys. Never lose the keystore file and the password for it! Without them, you will not be able to release an update for your game, and the project will have to be published again with a new name, losing all old users and reviews.
In the build settings, select Build App Bundle (Google Play). Unity will automatically collect all the necessary resources. After assembly, be sure to test the resulting file on a โcleanโ device that does not have the Unity editor installed. Often games work in the editor, but crash on pure Android due to missing system libraries.
Publishing process in Google Play Console requires filling out many fields: description, screenshots, content classification, privacy policy. Prepare these materials in advance. Also, do not forget about testing in a closed track before the open release in order to catch critical bugs on real user devices.
Why does my game crash immediately after launching on the phone?
Most often this is due to a mismatch in the processor architecture (for example, the build is only for x86, and the phone is on ARM) or the lack of necessary rights in the manifest. Also check the logs via adb logcat.
How to reduce the size of an APK file?
Use AAB format, enable texture compression (ASTC), delete unused assets, enable code stripping and use proxies to download heavy content over the network.
Do you need to support older versions Android?
Google Play requires a minimum API Level 21 (Android 5.0) for new applications. Supporting older versions will increase the audience, but complicate development and testing.
Can I update the game if I lost the signing key?
No. If you haven't used Play App Signing (where the key is stored by Google), then losing the developer key means you won't be able to update the app. You will have to create a new application with a new package.
What is the difference between IL2CPP and Mono?
IL2CPP converts C# code to C++ before compilation, which gives a performance boost and protects the code from reverse engineering. Mono is faster to compile, but slower to execute and easier to decompile.