There are two Android build process output types in Unity: the output package (APK) and the exported project. An APK is automatically deployed to your device if you select Build and Run. Alternatively, you can use Android Debug Bridge (ADB) to deploy the APK manually after building. For the full list of ADB commands, refer to the Android Debug Bridge section of the Android Developer documentation.
The output package includes APK expansion files (OBB) if the Split Application Binary option is selected in the Unity Editor’s Player Settings window. For more details on OBB files, refer to the OBB Support section of the Unity Manual
Unity supports two Android build systems: Gradle and Internal. Unity exports projects in two formats: ADT (Google Android project) and Gradle.
The Internal build system creates an APK by invoking Android SDK utilities in a specific order. Unity automatically performs a number of steps to create the APK, including:
Preparing and building the Unity Assets
Processing the plug-ins
Splitting the resources into the parts that go to the APK and the OBB, if Split Application Binary is selected
Building the Android resources using the AAPT utility
Generating the Android manifest and merging the library manifests into it
Compiling the Java code into the Dalvik Executable format (DEX)
Building the IL2CPP library, if IL2CPP Scripting Backend is selected
Building and optimizing the APK and OBB packages
The Gradle build system uses Gradle to build an APK or export a project in Gradle format, which can then be imported to Android Studio. For more details, see Unity documentation on Gradle for Android.
When you select this build system, Unity goes through the same steps as the Internal build system excluding resource compilation with AAPT and running DEX. Unity then generates the build.gradle file (along with the other required configuration files) and invokes the Gradle executable, passing it the task name and the working directory. The APK is then built by Gradle.
For more control over the build pipeline, or to make changes that Unity does not normally allow (for example, fine tuning the manifest files that are automatically generated by Unity), you must export your project for use with external tools.
Unity supports exporting projects in two formats:
Gradle project - Gradle projects are the recommended export format when exporting into Android Studio.
Google Android project (also known as ADT or Eclipse projects) - ADT projects can be imported into Eclipse or Android Studio (importing into Android converts the project to Gradle). This format is outdated and is no longer supported by Google.
To export the project:
Select Gradle or ADT in the Build Settings window (and check the Export Project checkbox if you have selected Gradle).
Click Export and select the destination folder.
When the export has finished, open Android Studio and import your project. For more information on importing projects to Android Studio, refer to the Migrate to Android Studio section of the Android Developer documentation.
In the Build Settings window, there is a Texture Compression option. By default, Unity uses the ETC texture format for textures that don’t have individual texture format overrides (see Unity documentaton on Textures for more information).
When building an APK to target specific hardware architecture, use the Texture Compression option to override this default behavior. Any texture that is not set to be compressed is left alone - only textures using a compressed texture format use the format selected in the Texture Compression option.
To make sure the app is only deployed on devices which support the selected texture compression, Unity edits the Android Manifest to include tags that match the particular format selected. This ensures that the Google Play Store filtering mechanism will only serve the app to devices with appropriate graphics hardware.
The Build Settings window offers two options: Build and Build and Run. When building, the output packages (APK and OBB, if enabled) are saved to the path that you select. You can publish these packages to the Google Play Store, or install them on your device manually with the help of ADB . For further information about installing apps manually, refer to the Running Your App section of the Android Developer documentation.
Selecting Build and Run saves the output packages to the file path you specify, while also installing your app on the Android device connected to your computer.
If the Split Application Binary option is enabled, the OBB file is pushed to the correct location on your device. If Development Build is checked, Unity also sets up a profiler tunnel and enables CheckJNI. After that, the app is launched.
Tip: Once you specify the output path for the packages, use the Ctrl+B (Windows) or Cmd+B (OSX) keyboard shortcut to Build and Run using the saved output path.
2017–05–25 Page published with editorial review
Updated functionality in 5.5