Get started with Android Resolver
Configure and use the Android Resolver to manage Android library dependencies in your project.
The Android Resolver copies specified dependencies from local or remote Maven repositories into the Unity project when you select Android as the build target in the Unity Editor.
For example, to add the Google Play Games library (com.google.android.gms:play-services-games package) at version 24.0.0 to a plug-in's Android dependencies:
<dependencies>
<androidPackages>
<androidPackage spec="com.google.android.gms:play-services-games:24.0.0">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
</androidPackage>
</androidPackages>
</dependencies>
The version specification element supports:
- Specific versions, for example
24.00. - Partial matches, for example
24.0.+matches24.0.0,24.0.1, and later versions. - Latest version using
LATESTor+. AvoidLATESTunless you're confident updates to the library will not break your Unity plug-in.
The previous example registers the dependency with the Android SDK Manager so it can install the package if it's missing. If your dependency is on Maven Central, declare it with the androidPackage element:
<dependencies>
<androidPackages>
<androidPackage spec="androidx.appcompat:appcompat:1.7.1"/>
</androidPackages>
</dependencies>
Configure auto resolution
By default, the Android Resolver automatically monitors the dependencies you have specified and the Plugins/Android folder of your Unity project. The resolution process runs when the specified dependencies aren't present in your project.
You can disable the auto resolution process in the Editor from Assets > External Dependency Manager > Android Resolver > Settings.
To resolve Android dependencies manually:
- Select Resolve from the Assets > External Dependency Manager > Android Resolver menu.
- If the Resolve operation fails, select Assets > External Dependency Manager > Android Resolver > Force Resolve.
Remove libraries
The Android Resolver tracks resolved packages using asset labels. To remove resolved packages, navigate to Assets > External Dependency Manager > Android Resolver > Delete Resolved Libraries.
Process Android manifest variables (deprecated)
Important
This feature is unsupported and will be removed in a future version of the package.
Some Android Archive (AAR) files contain variables that the Android Gradle plug-in might normally process. Unity's Internal Build System doesn't perform that processing, so the Android Resolver unpacks the AAR into a folder and replaces ${applicationId} with the bundle ID where supported.
You can disable AAR explosion and Android manifest processing in Assets > External Dependency Manager > Android Resolver > Settings menu. Disable AAR explosion if you export the project to build with Gradle or Android Studio.
Strip ABIs (deprecated)
Important
This feature is unsupported and will be removed in a future version of the package.
Some AAR files contain native libraries (.so files) for each Application Binary Interface (ABI) supported by Android. When targeting a single ABI (for example x86), Unity doesn't strip native libraries for unused ABIs. The Android Resolver can unpack the AAR and strip unused ABIs to reduce APK size. If libraries for multiple ABIs remain in the APK (for example, a mix of x86 and armeabi-v7a), Android can load the wrong library for the current ABI and break your plug-in on some devices.
You can disable AAR explosion (and ABI stripping) in the Assets > External Dependency Manager > Android Resolver > Settings menu. Disable explosion if you export the project to build with Gradle or Android Studio.
Choose a resolution strategy
By default, the Android Resolver uses Gradle to download dependencies before integrating them into your Unity project.
Change the resolution strategy in the Assets > External Dependency Manager > Android Resolver > Settings menu.
Download artifacts with Gradle (deprecated)
Important
This method is deprecated and will be removed in a future version of the package.
Using the default resolution strategy, the Android Resolver executes the following operations:
- Removes the result of previous Android resolutions. For example, delete all files and directories labeled with
gpsrunderPlugins/Androidfrom the project. - Collects the set of Android dependencies (libraries) specified by a project's
*Dependencies.xmlfiles. - Runs
download_artifacts.gradlewith Gradle to resolve conflicts and, if successful, download the set of resolved Android libraries (AARs, JARs). - Processes each AAR/JAR so that it can be used with the currently selected Unity build system (for example Internal versus Gradle, Export versus No Export). This involves patching each reference to
applicationIdin theAndroidManifest.xmlwith the project's bundle ID. This means resolution must be run again if the bundle ID has changed. - Moves the processed AARs to
Plugins/Androidso they will be included when Unity invokes the Android build.
Integrate into mainTemplate.gradle
When the Patch mainTemplate.gradle setting is enabled, rather than downloading artifacts before the build, Android resolution results in the execution of the following operations:
- Remove the result of previous Android resolutions. For example, delete all files and directories labeled with
gpsrunderPlugins/Androidfrom the project and remove sections delimited with// Android Resolver * Startand// Android Resolver * Endlines. - Collect the set of Android dependencies (libraries) specified by a project's
*Dependencies.xmlfiles. - Rename any
.srcaarfiles in the build to.aarand exclude them from being included directly by Unity in the Android build.mainTemplate.gradlewill be patched to include them instead of using local maven repositories. - Inject the required Gradle repositories into
mainTemplate.gradleat the line matching the pattern.*apply plugin: 'com\.android\.(application|library)'.*or the section starting at the line// Android Resolver Repos Start. If you want to control the injection point in the file, place the section delimited by the lines// Android Resolver Repos Startand// Android Resolver Repos Endin the global scope before thedependenciessection. - Inject the required Android dependencies (libraries) into
mainTemplate.gradleat the line matching the pattern***DEPS***or the section starting at the line// Android Resolver Dependencies Start. If you want to control the injection point in the file, place the section delimited by the lines// Android Resolver Dependencies Startand// Android Resolver Dependencies Endin thedependenciessection. - Inject the packaging options logic, which excludes architecture specific libraries based upon the selected build target, into
mainTemplate.gradleat the line matching the patternandroid +{or the section starting at the line// Android Resolver Exclusions Start. If you want to control the injection point in the file, place the section delimited by the lines// Android Resolver Exclusions Startand// Android Resolver Exclusions Endin the global scope before theandroidsection.
Tracck dependencies
The Android Resolver creates the ProjectSettings/AndroidResolverDependencies.xml file to record the set of resolved dependencies in a project. Auto-resolution uses this file to decide when to run resolution again.
View resolved dependencies
To view a list of the dependencies the Android Resolver has resolved in your project, navigate to Assets > External Dependency Manager > Android Resolver > Display Libraries.