Getting started with Android
How Unity builds Android applications
Unity uses GradleAn Android build system that automates several build processes. This automation means that many common build errors are less likely to occur. More info
See in Glossary to build Android applications so it is useful to understand the build process and how Unity interacts with Gradle. Gradle lets you use Player SettingsSettings that let you set various player-specific options for the final game built by Unity. More info
See in Glossary and other Unity windows to configure most aspects of the final build, however for more control, you must overwrite manifestThere are two types of manifest files: project manifests and package manifests.
See in Glossary and template files, or export your project and edit it in Android Studio.
The build process
To build Android applications:
- Unity collects project resources, code libraries, plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary, Gradle templates, and manifest templates from your Unity project and uses them to create a valid Gradle project.
- Unity adds and updates values inside Gradle templates and manifest files based on the Unity project’s Player Settings and Build Settings.
- If you chose to export the project and not build it, and use the IL2CPPA Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms. More info
See in Glossary scripting backendA framework that powers scripting in Unity. Unity supports three different scripting backends depending on target platform: Mono, .NET and IL2CPP. Universal Windows Platform, however, supports only two: .NET and IL2CPP. More info
See in Glossary, Unity places C++ source files produced from your C# scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary into the Gradle project. Otherwise, if you chose to build the project, Unity places the libil2cpp.so
library into the Gradle project.
- Unity calls OnPostGenerateGradleAndroidProject for all IPostGenerateGradleAndroidProject interfaces. You can use this callback to modify or move files before Gradle builds the application.
- Unity runs Gradle to build the application from the Gradle project. Gradle merges the Unity Library Manifest, Unity Launcher Manifest, and plug-in manifests into one Android App Manifest file.
Incremental build pipeline
Unity uses the incremental build pipeline when it builds the Player for Android. See the following Android-specific incremental build pipeline behaviors:
- Unity incrementally builds/generates:
- Unity incrementally copies:
- Player binaries
- Gradle resources
- The last step in the build process is to run Gradle. From this point, the build process doesn’t use the incremental build pipeline and it’s up to Gradle to track dependenciesIn the context of the Package Manager, a dependency is a specific package version (expressed in the form
package_name@package_version
) that a project or another package requires in order to work. Projects and packages use the dependencies attribute in their manifests to define the set of packages they require. For projects, these are considered direct dependencies; for packages, these are indirect, or transitive, dependencies. More info
See in Glossary.
If you implement callbacks that modify or move any Android file or asset that the incremental build pipeline uses, see Creating non-incremental builds.
Getting started with Android