GithubHelp home page GithubHelp logo

googlesamples / unity-jar-resolver Goto Github PK

View Code? Open in Web Editor NEW
1.2K 68.0 336.0 247.18 MB

Unity plugin which resolves Android & iOS dependencies and performs version management

License: Other

C# 80.96% Shell 0.40% Python 18.64%
unity-plugin unity android-resolver ios-resolver jar-resolver android-dependency cocoapods unity-android unity-ios unity-package-manager

unity-jar-resolver's Introduction

External Dependency Manager for Unity

openupm openupm

Overview

The External Dependency Manager for Unity (EDM4U) (formerly Play Services Resolver/Jar Resolver) is intended to be used by any Unity package or user that requires:

  • Android specific libraries (e.g AARs)

  • iOS CocoaPods

  • Version management of transitive dependencies

  • Management of Package Manager (PM) Registries

If you want to add and use iOS/Android dependencies directly in your project, then you should to install EDM4U in your project.

If you are a package user and the plugin you are using depends on EDM4U, and the package does not include EDM4U as a package dependency already, then you should to install EDM4U in your project.

If you are a UPM package maintainer and your package requires EDM4U, then you should add EDM4U as a package dependency in your package manifest (package.json):

{
  "dependencies": {
    "com.google.external-dependency-manager": "1.2.178"
  }
}

You should still install EDM4U to test out the package during development.

If you are a legacy .unitypackage package maintainer and your package requires EDM4U, please ask the user to install EDM4U separately. You should install EDM4U to test out the package during development.

Updated releases are available on GitHub

Requirements

The Android Resolver and iOS Resolver components of the plugin only work with Unity version 4.6.8 or higher.

The Version Handler component only works with Unity 5.x or higher as it depends upon the PluginImporter UnityEditor API.

The Package Manager Resolver component only works with Unity 2018.4 or above, when scoped registry support was added to the Package Manager.

Getting Started

Check out troubleshooting if you need help.

Install via OpenUPM

EDM4U is available on OpenUPM:

openupm add com.google.external-dependency-manager

Install via Google APIs for Unity

EDM4U is available both in UPM and legacy .unitypackage formats on Google APIs for Unity.

You may install the UPM version (.tgz) as a local UPM package.

You can also install EDM4U in your project as a .unitypackage. This is not recommended due to potential conflicts.

Conflict Resolution

For historical reasons, a package maintainer may choose to embed EDM4U in their package for ease of installation. This will create a conflict when you try to install EDM4U with the steps above, or with another package with embedded EDM4U. If your project imported a .unitypackage that has a copy of EDM4U embedded in it, you may safely delete it from your Assets folder. If your project depends on another UPM package with EDM4U, please reach out to the package maintainer and ask them to replace it with a dependency to this package. In the meantime, you can workaround the issue by copying the package to your Packages folder (to create an embedded package) and perform the steps yourself to avoid a dependency conflict.

Config file

To start adding dependencies to your project, copy and rename the SampleDependencies.xml file into your plugin and add the dependencies your project requires.

The XML file needs to be under an Editor directory and match the name *Dependencies.xml. For example, MyPlugin/Editor/MyPluginDependencies.xml.

Usages

Android Resolver

The Android Resolver copies specified dependencies from local or remote Maven repositories into the Unity project when a user selects 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 9.8.0 to the set of a plugin's Android dependencies:

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.gms:play-services-games:9.8.0">
      <androidSdkPackageIds>
        <androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
      </androidSdkPackageIds>
    </androidPackage>
  </androidPackages>
</dependencies>

The version specification (last component) supports:

  • Specific versions e.g 9.8.0

  • Partial matches e.g 9.8.+ would match 9.8.0, 9.8.1 etc. choosing the most recent version

  • Latest version using LATEST or +. We do not recommend using this unless you're 100% sure the library you depend upon will not break your Unity plugin in future

The above example specifies the dependency as a component of the Android SDK manager such that the Android SDK manager will be executed to install the package if it's not found. If your Android dependency is located on Maven central it's possible to specify the package simply using the androidPackage element:

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.api-client:google-api-client-android:1.22.0" />
  </androidPackages>
</dependencies>

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 are not present in your project.

The auto-resolution process can be disabled via the Assets > External Dependency Manager > Android Resolver > Settings menu.

Manual resolution can be performed using the following menu options:

  • Assets > External Dependency Manager > Android Resolver > Resolve

  • Assets > External Dependency Manager > Android Resolver > Force Resolve

Deleting libraries

Resolved packages are tracked via asset labels by the Android Resolver. They can easily be deleted using the Assets > External Dependency Manager > Android Resolver > Delete Resolved Libraries menu item.

Android Manifest Variable Processing

Some AAR files (for example play-services-measurement) contain variables that are processed by the Android Gradle plugin. Unfortunately, Unity does not perform the same processing when using Unity's Internal Build System, so the Android Resolver plugin handles known cases of this variable substitution by exploding the AAR into a folder and replacing ${applicationId} with the bundleID.

Disabling AAR explosion and therefore Android manifest processing can be done via the Assets > External Dependency Manager > Android Resolver > Settings menu. You may want to disable explosion of AARs if you're exporting a project to be built with Gradle/Android Studio.

ABI Stripping

Some AAR files contain native libraries (.so files) for each ABI supported by Android. Unfortunately, when targeting a single ABI (e.g x86), Unity does not strip native libraries for unused ABIs. To strip unused ABIs, the Android Resolver plugin explodes an AAR into a folder and removes unused ABIs to reduce the built APK size. Furthermore, if native libraries are not stripped from an APK (e.g you have a mix of Unity's x86 library and some armeabi-v7a libraries) Android may attempt to load the wrong library for the current runtime ABI completely breaking your plugin when targeting some architectures.

AAR explosion and therefore ABI stripping can be disabled via the Assets > External Dependency Manager > Android Resolver > Settings menu. You may want to disable explosion of AARs if you're exporting a project to be built with Gradle/Android Studio.

Resolution Strategies

By default the Android Resolver will use Gradle to download dependencies prior to integrating them into a Unity project. This works with Unity's internal build system and Gradle/Android Studio project export.

It's possible to change the resolution strategy via the Assets > External Dependency Manager > Android Resolver > Settings menu.

Download Artifacts with Gradle

Using the default resolution strategy, the Android resolver executes the following operations:

  • Remove the result of previous Android resolutions. E.g Delete all files and directories labeled with "gpsr" under Plugins/Android from the project.

  • Collect the set of Android dependencies (libraries) specified by a project's *Dependencies.xml files.

  • Run download_artifacts.gradle with Gradle to resolve conflicts and, if successful, download the set of resolved Android libraries (AARs, JARs).

  • Process each AAR/JAR so that it can be used with the currently selected Unity build system (e.g Internal vs. Gradle, Export vs. No Export). This involves patching each reference to applicationId in the AndroidManifest.xml with the project's bundle ID. This means resolution must be run again if the bundle ID has changed.

  • Move the processed AARs to Plugins/Android so they will be included when Unity invokes the Android build.

Integrate into mainTemplate.gradle

Unity 5.6 introduced support for customizing the build.gradle used to build Unity projects with 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. E.g Delete all files and directories labeled with "gpsr" under Plugins/Android from the project and remove sections delimited with // Android Resolver * Start and // Android Resolver * End lines.

  • Collect the set of Android dependencies (libraries) specified by a project's *Dependencies.xml files.

  • Rename any .srcaar files in the build to .aar and exclude them from being included directly by Unity in the Android build as mainTemplate.gradle will be patched to include them instead from their local maven repositories.

  • Inject the required Gradle repositories into mainTemplate.gradle at 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, the section delimited by the lines // Android Resolver Repos Start and // Android Resolver Repos End should be placed in the global scope before the dependencies section.

  • Inject the required Android dependencies (libraries) into mainTemplate.gradle at 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, the section delimited by the lines // Android Resolver Dependencies Start and // Android Resolver Dependencies End should be placed in the dependencies section.

  • Inject the packaging options logic, which excludes architecture specific libraries based upon the selected build target, into mainTemplate.gradle at the line matching the pattern android +{ or the section starting at the line // Android Resolver Exclusions Start. If you want to control the injection point in the file, the section delimited by the lines // Android Resolver Exclusions Start and // Android Resolver Exclusions End should be placed in the global scope before the android section.

Dependency Tracking

The Android Resolver creates the ProjectSettings/AndroidResolverDependencies.xml to quickly determine the set of resolved dependencies in a project. This is used by the auto-resolution process to only run the expensive resolution process when necessary.

Displaying Dependencies

It's possible to display the set of dependencies the Android Resolver would download and process in your project via the Assets > External Dependency Manager > Android Resolver > Display Libraries menu item.

iOS Resolver

The iOS resolver component of this plugin manages CocoaPods. A CocoaPods Podfile is generated and the pod tool is executed as a post build process step to add dependencies to the Xcode project exported by Unity.

Dependencies for iOS are added by referring to CocoaPods.

For example, to add the AdMob pod, version 7.0 or greater with bitcode enabled:

<dependencies>
  <iosPods>
    <iosPod name="Google-Mobile-Ads-SDK" version="~> 7.0" bitcodeEnabled="true"
            minTargetSdk="6.0" addToAllTargets="false" />
  </iosPods>
</dependencies>

Integration Strategies

The CocoaPods are either:

  • Downloaded and injected into the Xcode project file directly, rather than creating a separate xcworkspace. We call this Xcode project integration.

  • If the Unity version supports opening a xcworkspace file, the pod tool is used as intended to generate a xcworkspace which references the CocoaPods. We call this Xcode workspace integration.

The resolution strategy can be changed via the Assets > External Dependency Manager > iOS Resolver > Settings menu.

Appending text to generated Podfile

In order to modify the generated Podfile you can create a script like this:

using System.IO;

using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;

public class PostProcessIOS : MonoBehaviour
{
    // Must be between 40 and 50 to ensure that it's not overriden by Podfile generation (40) and
    // that it's added before "pod install" (50).
    [PostProcessBuildAttribute(45)]
    private static void PostProcessBuild_iOS(BuildTarget target, string buildPath)
    {
        if (target == BuildTarget.iOS)
        {
            using (StreamWriter sw = File.AppendText(buildPath + "/Podfile"))
            {
                // E.g. add an app extension
                sw.WriteLine("\ntarget 'NSExtension' do\n  pod 'Firebase/Messaging', '6.6.0'\nend");
            }
        }
    }
}

Package Manager Resolver

Adding registries to the Package Manager (PM) is a manual process. The Package Manager Resolver (PMR) component of this plugin makes it easy for plugin maintainers to distribute new PM registry servers and easy for plugin users to manage PM registry servers.

Adding Registries

For example, to add a registry for plugins in the scope com.coolstuff:

<registries>
  <registry name="Cool Stuff"
            url="https://unityregistry.coolstuff.com"
            termsOfService="https://coolstuff.com/unityregistry/terms"
            privacyPolicy="https://coolstuff.com/unityregistry/privacy">
    <scopes>
      <scope>com.coolstuff</scope>
    </scopes>
  </registry>
</registries>

When PMR is loaded it will prompt the developer to add the registry to their project if it isn't already present in the Packages/manifest.json file.

For more information, see Unity's documentation on scoped package registries.

Managing Registries

It's possible to add and remove registries that are specified via PMR XML configuration files via the following menu options:

  • Assets > External Dependency Manager > Package Manager Resolver > Add Registries will prompt the user with a window which allows them to add registries discovered in the project to the Package Manager.

  • Assets > External Dependency Manager > Package Manager Resolver > Remove Registries will prompt the user with a window which allows them to remove registries discovered in the project from the Package Manager.

  • Assets > External Dependency Manager > Package Manager Resolver > Modify Registries will prompt the user with a window which allows them to add or remove registries discovered in the project.

Migration

PMR can migrate Version Handler packages installed in the Assets folder to PM packages. This requires the plugins to implement the following:

  • .unitypackage must include a Version Handler manifests that describes the components of the plugin. If the plugin has no dependencies the manifest would just include the files in the plugin.

  • The PM package JSON provided by the registry must include a keyword (in the versions.VERSION.keyword list) that maps the PM package to a Version Handler package using the format vh-name:VERSION_HANDLER_MANIFEST_NAME where VERSION_HANDLER_MANIFEST_NAME is the name of the manifest defined in the .unitypackage. For more information see the description of the gvhp_manifestname asset label in the Version Handler section.

When using the Assets > External Dependency Manager > Package Manager Resolver > Migrate Packages menu option, PMR then will:

  • List all Version Handler manager packages in the project.

  • Search all available packages in the PM registries and fetch keywords associated with each package parsing the Version Handler manifest names for each package.

  • Map each installed Version Handler package to a PM package.

  • Prompt the user to migrate the discovered packages.

  • Perform package migration for all selected packages if the user clicks the Apply button.

Configuration

PMR can be configured via the Assets > External Dependency Manager > Package Manager Resolver > Settings menu option:

  • Add package registries when enabled, when the plugin loads or registry configuration files change, this will prompt the user to add registries that are not present in the Package Manager.

  • Prompt to add package registries will cause a developer to be prompted with a window that will ask for confirmation before adding registries. When this is disabled registries are added silently to the project.

  • Prompt to migrate packages will cause a developer to be prompted with a window that will ask for confirmation before migrating packages installed in the Assets directory to PM packages.

  • Enable Analytics Reporting when enabled, reports the use of the plugin to the developers so they can make imrpovements.

  • Verbose logging when enabled prints debug information to the console which can be useful when filing bug reports.

Version Handler

The Version Handler component of this plugin manages:

  • Shared Unity plugin dependencies.

  • Upgrading Unity plugins by cleaning up old files from previous versions.

  • Uninstallation of plugins that are distributed with manifest files.

  • Restoration of plugin assets to their original install locations if assets are tagged with the exportpath label.

Since the Version Handler needs to modify Unity asset metadata (.meta files), to enable/disable components, rename and delete asset files it does not work with Package Manager installed packages. It's still possible to include EDM4U in Package Manager packages, the Version Handler component simply won't do anything to PM plugins in this case.

Using Version Handler Managed Plugins

If a plugin is imported at multiple different versions into a project, if the Version Handler is enabled, it will automatically check all managed assets to determine the set of assets that are out of date and assets that should be removed. To disable automatic checking managed assets disable the Enable version management option in the Assets > External Dependency Manager > Version Handler > Settings menu.

If version management is disabled, it's possible to check managed assets manually using the Assets > External Dependency Manager > Version Handler > Update menu option.

Listing Managed Plugins

Plugins managed by the Version Handler, those that ship with manifest files, can displayed using the Assets > External Dependency Manager > Version Handler > Display Managed Packages menu option. The list of plugins are written to the console window along with the set of files used by each plugin.

Uninstalling Managed Plugins

Plugins managed by the Version Handler, those that ship with manifest files, can be removed using the Assets > External Dependency Manager > Version Handler > Uninstall Managed Packages menu option. This operation will display a window that allows a developer to select a set of plugins to remove which will remove all files owned by each plugin excluding those that are in use by other installed plugins.

Files managed by the Version Handler, those labeled with the gvh asset label, can be checked to see whether anything needs to be upgraded, disabled or removed using the Assets > External Dependency Manager > Version Handler > Update menu option.

Restore Install Paths

Some developers move assets around in their project which can make it harder for plugin maintainers to debug issues if this breaks Unity's special folders rules. If assets are labeled with their original install/export path (see gvhp_exportpath below), Version Handler can restore assets to their original locations when using the Assets > External Dependency Manager > Version Handler > Move Files To Install Locations menu option.

Settings

Some behavior of the Version Handler can be configured via the Assets > External Dependency Manager > Version Handler > Settings menu option.

  • Enable version management controls whether the plugin should automatically check asset versions and apply changes. If this is disabled the process should be run manually when installing or upgrading managed plugins using Assets > External Dependency Manager > Version Handler > Update.

  • Rename to canonical filenames is a legacy option that will rename files to remove version numbers and other labels from filenames.

  • Prompt for obsolete file deletion enables the display of a window when obsolete files are deleted allowing the developer to select which files to delete and those to keep.

  • Allow disabling files via renaming controls whether obsolete or disabled files should be disabled by renaming them to myfilename_DISABLED. Renaming to disable files is required in some scenarios where Unity doesn't support removing files from the build via the PluginImporter.

  • Enable Analytics Reporting enables/disables usage reporting to plugin developers to improve the product.

  • Verbose logging enables very noisy log output that is useful for debugging while filing a bug report or building a new managed plugin.

  • Use project settings saves settings for the plugin in the project rather than system-wide.

Redistributing a Managed Plugin

The Version Handler employs a couple of methods for managing version selection, upgrade and removal of plugins.

  • Each plugin can ship with a manifest file that lists the files it includes. This makes it possible for Version Handler to calculate the difference in assets between the most recent release of a plugin and the previous release installed in a project. If a files are removed the Version Handler will prompt the user to clean up obsolete files.

  • Plugins can ship using assets with unique names, unique GUIDs and version number labels. Version numbers can be attached to assets using labels or added to the filename (e.g myfile.txt would be `myfile_version-x.y.z.txt). This allows the Version Handler to determine which set of files are the same file at different versions, select the most recent version and prompt the developer to clean up old versions.

Unity plugins can be managed by the Version Handler using the following steps:

  1. Add the gvh asset label to each asset (file) you want Version Handler to manage.

  2. Add the gvh_version-VERSION label to each asset where VERSION is the version of the plugin you're releasing (e.g 1.2.3).

  3. Add the gvhp_exportpath-PATH label to each asset where PATH is the export path of the file when the .unitypackage is created. This is used to track files if they're moved around in a project by developers.

  4. Optional: Add gvh_targets-editor label to each editor DLL in your plugin and disable editor as a target platform for the DLL. The Version Handler will enable the most recent version of this DLL when the plugin is imported.

  5. Optional: If your plugin is included in other Unity plugins, you should add the version number to each filename and change the GUID of each asset. This allows multiple versions of your plugin to be imported into a Unity project, with the Version Handler component activating only the most recent version.

  6. Create a manifest text file named MY_UNIQUE_PLUGIN_NAME_VERSION.txt that lists all the files in your plugin relative to the project root. Then add the gvh_manifest label to the asset to indicate this file is a plugin manifest.

  7. Optional: Add a gvhp_manifestname-NAME label to your manifest file to provide a human readable name for your package. If this isn't provided the name of the manifest file will be used as the package name. NAME can match the pattern [0-9]+[a-zA-Z -] where a leading integer will set the priority of the name where 0 is the highest priority and preferably used as the display name. The lowest value (i.e highest priority name) will be used as the display name and all other specified names will be aliases of the display name. Aliases can refer to previous names of the package allowing renaming across published versions.

  8. Redistribute EDM4U Unity plugin with your plugin. See the Plugin Redistribution section for details.

If you follow these steps:

  • When users import a newer version of your plugin, files referenced by the older version's manifest are cleaned up.

  • The latest version of the plugin will be selected when users import multiple packages that include your plugin, assuming the steps in Plugin Redistribution are followed.

Background

Many Unity plugins have dependencies upon Android specific libraries, iOS CocoaPods, and sometimes have transitive dependencies upon other Unity plugins. This causes the following problems:

  • Integrating platform specific (e.g Android and iOS) libraries within a Unity project can be complex and a burden on a Unity plugin maintainer.
  • The process of resolving conflicting dependencies on platform specific libraries is pushed to the developer attempting to use a Unity plugin. The developer trying to use your plugin is very likely to give up when faced with Android or iOS specific build errors.
  • The process of resolving conflicting Unity plugins (due to shared Unity plugin components) is pushed to the developer attempting to use your Unity plugin. In an effort to resolve conflicts, the developer will very likely attempt to resolve problems by deleting random files in your plugin, report bugs when that doesn't work and finally give up.

EDM4U provides solutions for each of these problems.

Android Dependency Management

The Android Resolver component of this plugin will download and integrate Android library dependencies and handle any conflicts between plugins that share the same dependencies.

Without the Android Resolver, typically Unity plugins bundle their AAR and JAR dependencies, e.g. a Unity plugin SomePlugin that requires the Google Play Games Android library would redistribute the library and its transitive dependencies in the folder SomePlugin/Android/. When a user imports SomeOtherPlugin that includes the same libraries (potentially at different versions) in SomeOtherPlugin/Android/, the developer using SomePlugin and SomeOtherPlugin will see an error when building for Android that can be hard to interpret.

Using the Android Resolver to manage Android library dependencies:

  • Solves Android library conflicts between plugins.
  • Handles all of the various processing steps required to use Android libraries (AARs, JARs) in Unity 4.x and above projects. Almost all versions of Unity have - at best - partial support for AARs.
  • (Experimental) Supports minification of included Java components without exporting a project.

iOS Dependency Management

The iOS Resolver component of this plugin integrates with CocoaPods to download and integrate iOS libraries and frameworks into the Xcode project Unity generates when building for iOS. Using CocoaPods allows multiple plugins to utilize shared components without forcing developers to fix either duplicate or incompatible versions of libraries included through multiple Unity plugins in their project.

Package Manager Registry Setup

The Package Manager (PM) makes use of NPM registry servers for package hosting and provides ways to discover, install, upgrade and uninstall packages. This makes it easier for developers to manage plugins within their projects.

However, installing additional package registries requires a few manual steps that can potentially be error prone. The Package Manager Resolver component of this plugin integrates with PM to provide a way to auto-install PM package registries when a .unitypackage is installed which allows plugin maintainers to ship a .unitypackage that can provide access to their own PM registry server to make it easier for developers to manage their plugins.

Unity Plugin Version Management

Finally, the Version Handler component of this plugin simplifies the process of managing transitive dependencies of Unity plugins and each plugin's upgrade process.

For example, without the Version Handler plugin, if:

  • Unity plugin SomePlugin includes EDM4U plugin at version 1.1.
  • Unity plugin SomeOtherPlugin includes EDM4U plugin at version 1.2.

The version of EDM4U included in the developer's project depends upon the order the developer imports SomePlugin or SomeOtherPlugin.

This results in:

  • EDM4U at version 1.2, if SomePlugin is imported then SomeOtherPlugin is imported.
  • EDM4U at version 1.1, if SomeOtherPlugin is imported then SomePlugin is imported.

The Version Handler solves the problem of managing transitive dependencies by:

  • Specifying a set of packaging requirements that enable a plugin at different versions to be imported into a Unity project.
  • Providing activation logic that selects the latest version of a plugin within a project.

When using the Version Handler to manage EDM4U included in SomePlugin and SomeOtherPlugin, from the prior example, version 1.2 will always be the version activated in a developer's Unity project.

Plugin creators are encouraged to adopt this library to ease integration for their customers. For more information about integrating EDM4U into your own plugin, see the Plugin Redistribution section of this document.

Analytics

The External Dependency Manager for Unity plugin by default logs usage to Google Analytics. The purpose of the logging is to quantitatively measure the usage of functionality, to gather reports on integration failures and to inform future improvements to the developer experience of the External Dependency Manager plugin. Note that the analytics collected are limited to the scope of the EDM4U pluginโ€™s usage.

For details of what is logged, please refer to the usage of EditorMeasurement.Report() in the source code.

Plugin Redistribution

If you are a package maintainer and your package depends on EDM4U, it is highly recommended to use the UPM format and add EDM4U as a dependency. If you must include it in your .unitypackage, redistributing EDM4U inside your own plugin might ease the integration process for your users.

If you wish to redistribute EDM4U inside your plugin, you must follow these steps when importing the external-dependency-manager-*.unitypackage, and when exporting your own plugin package:

  1. Import the external-dependency-manager-*.unitypackage into your plugin project by running Unity from the command line, ensuring that you add the -gvh_disable option.
  2. Export your plugin by running Unity from the command line, ensuring that you:
    • Include the contents of the Assets/PlayServicesResolver and Assets/ExternalDependencyManager directory.
    • Add the -gvh_disable option.

You must specify the -gvh_disable option in order for the Version Handler to work correctly!

For example, the following command will import the external-dependency-manager-1.2.46.0.unitypackage into the project MyPluginProject and export the entire Assets folder to MyPlugin.unitypackage:

Unity -gvh_disable \
      -batchmode \
      -importPackage external-dependency-manager-1.2.46.0.unitypackage \
      -projectPath MyPluginProject \
      -exportPackage Assets MyPlugin.unitypackage \
      -quit

Background

The Version Handler component relies upon deferring the load of editor DLLs so that it can run first and determine the latest version of a plugin component to activate. The build of EDM4U plugin has Unity asset metadata that is configured so that the editor components are not initially enabled when it's imported into a Unity project. To maintain this configuration when importing the external-dependency-manager.unitypackage into a Unity plugin project, you must specify the command line option -gvh_disable which will prevent the Version Handler component from running and changing the Unity asset metadata.

Building from Source

To build this plugin from source you need the following tools installed: * Unity 2021 and below (with iOS and Android modules installed) * Java 11

You can build the plugin by running the following from your shell (Linux / OSX):

./gradlew build

or Windows:

./gradlew.bat build

If Java 11 is not your default Java command, add -Dorg.gradle.java.home=<PATH_TO_JAVA_HOME> to the command above.

Testing

You can run the tests by running the following from your shell (Linux / OSX):

./gradlew test

or Windows:

./gradlew.bat test

The following properties can be set to narrow down the tests to run or change the test run behavior.

  • INTERACTIVE_MODE_TESTS_ENABLED - Default to 1. Set to 1 to enable interactive mode tests, which requires GPU on the machine. Otherwise, only run tests in the batch mode.
  • INCLUDE_TEST_TYPES - Default to empty string, which means to include every type of the test. To narrow down the types of test to run, set this properties with a list of case-insensitive type strings separated by comma. For instance, -PINCLUDE_TEST_TYPES="Python,NUnit" means to include only Python tests and NUnit tests. See TestTypeEnum in build.gradle for available options.
  • EXCLUDE_TEST_TYPES - Default to empty string, which means to exclude none. To add types of tests to exclude, set this properties with a list of case-insensitive type strings separated by comma. For instance, -PEXCLUDE_TEST_TYPES="Python,NUnit" means to exclude Python tests and NUnit tests. See TestTypeEnum in build.gradle for available options.
  • INCLUDE_TEST_MODULES - Default to empty string, which means to include the tests for every modules. To narrow down modules to test, set this properties with a list of case-insensitive module strings separated by comma. For instance, -PINCLUDE_TEST_MODULES="Tool,AndroidResolver" means to run tests for tools and Android Resolver only. See TestModuleEnum in build.gradle for available options.
  • EXCLUDE_TEST_MODULES - Default to empty string, which means to exclude none. To add modules to exclude, set this properties with a list of case-insensitive module strings separated by comma. For instance, -PEXCLUDE_TEST_MODULES="Tool,AndroidResolver" means to run tests for any modules other than tools and Android Resolver. See TestModuleEnum in build.gradle for available options.
  • EXCLUDE_TESTS - Default to empty string, which means to exclude none. To add tests to exclude, set this properties with a list of case-insensitive test names separated by comma. For instance, -PEXCLUDE_TESTS="testGenGuids,testDownloadArtifacts" means to run tests except the tests with name of testGenGuids and testDownloadArtifacts.
  • CONTINUE_ON_FAIL_FOR_TESTS_ENABLED - Default to 1. Set to 1 to continue running the next test when the current one fails. Otherwise, the build script stops whenever any test fails.

For instance, by running the following command, it only runs the Unity integration tests that does not requires GPU, but exclude tests for Android Resolver module and iOS Resolver module.

./gradlew test \
  -PINTERACTIVE_MODE_TESTS_ENABLED=0 \
  -PINCLUDE_TEST_TYPES="Integration" \
  -PEXCLUDE_TEST_MODULES="AndroidResolver,iOSResolver"

Releasing

Each time a new build of this plugin is checked into the source tree you need to do the following:

  • Bump the plugin version variable pluginVersion in build.gradle
  • Update CHANGELOG.md with the new version number and changes included in the release.
  • Build the release using ./gradlew release which performs the following:
    • Updates external-dependency-manager-*.unitypackage
    • Copies the unpacked plugin to the exploded directory.
    • Updates template metadata files in the plugin directory. The GUIDs of all asset metadata is modified due to the version number change. Each file within the plugin is versioned to allow multiple versions of the plugin to be imported into a Unity project which allows the most recent version to be activated by the Version Handler component.
  • Create release commit using ./gradlew gitCreateReleaseCommit which performs git commit -a -m "description from CHANGELOG.md"
  • Once the release commit is merge, tag the release using ./gradlew gitTagRelease which performs the following:
    • git tag -a pluginVersion -m "version RELEASE" to tag the release.
  • Update tags on remote branch using git push --tag REMOTE HEAD:master

unity-jar-resolver's People

Contributors

a-maurice avatar almostmatt avatar benwulfe avatar bopangzz avatar chkuang-g avatar claywilkinson avatar davidrogers-unity avatar dellabitta avatar dzlier-gcp avatar f1yingbanana avatar jimmydeemo avatar joefspiro avatar johnb003 avatar kunny avatar marfx000 avatar paulb777 avatar pavelgj avatar pimdewitte avatar prime31 avatar rampara avatar rodgreen avatar rpgg avatar ryanmeier avatar santoshbagadi avatar schnecle avatar sdolim avatar si1ver avatar spacepluk avatar unace2u avatar vimanyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-jar-resolver's Issues

Can't finish step 1

Following the instructions here:
https://github.com/googlesamples/unity-jar-resolver#usage

I downloaded the unitypackage:
https://github.com/googlesamples/unity-jar-resolver/blob/master/play-services-resolver-1.2.21.0.unitypackage
And added it to my unity project

I put a copy of this file in my project:
https://github.com/googlesamples/unity-jar-resolver/blob/master/sample/Assets/PlayServicesResolver/Editor/SampleDependencies.cs

This is where I'm stuck.
Assets/PlayServicesResolver/Editor/SampleDependencies.cs(69,36): error CS0103: The name `Google' does not exist in the current context

This issue:
#26
Remains unanswered for previous people with this question.

iOS custom pod spec file

Is thr a way to specify a custom pod spec file like this and ensure that this file will be copied just like GoogleServices-Info.plist gets copied while using google sdks ?

pod 'Firebase/Messaging', :podspec => 'FirebaseMessaging.podspec.json'

This way i can exclude an unnecessary dependency which publisher of unitypackage has provided otherwise with it.

Usage is error prone with reflection calls, Proposed strongly typed solution.

Currently, Jar Resolver requires some pretty ugly and unmaintainable reflection calls to get things working. What I have done personally is create a simple class that hides all the reflection and lets you use a strongly typed, easy to read/maintain API to access Jar Resolver.

An example usage of the API is below. It is more clear, less error prone and easier on the eyes than the SampleDependencies.

[InitializeOnLoad]
public class PlayGameServicesDependencies : AssetPostprocessor
{
	static PlayGameServicesDependencies()
	{
		JarResolver.createSupportInstance( typeof( PlayGameServicesDependencies ).Name )
			.dependOn( "com.google.android.gms", "play-services-games", "9+", new string[] { "extra-google-m2repository" } )
			.dependOn( "com.google.android.gms", "play-services-plus", "9+", new string[] { "extra-google-m2repository" } );
	}
}

The code for the class is below. If this is something that you would like to have in the repo let me know and I can send over a pull request. If not, feel free to close this issue.

namespace Google
{
	public class JarResolver
	{
		public class JarResolverImpl
		{
			object _svcSupport;

			public JarResolverImpl()
			{}


			public JarResolverImpl( object svcSupport )
			{
				_svcSupport = svcSupport;
			}


			public JarResolverImpl DependOn( string group, string artifact, string version, string[] packageIds = null, string[] repositories = null )
			{
				if( _svcSupport != null )
				{
					Google.VersionHandler.InvokeInstanceMethod( _svcSupport, "DependOn",
						new object[] { group, artifact, version },
						namedArgs: new Dictionary<string, object>()
						{
							{ "packageIds", packageIds },
							{ "repositories", repositories }
						});
				}

				return this;
			}
		}


		public static JarResolverImpl CreateSupportInstance( string clientName )
		{
#if !UNITY_ANDROID
			// if we arent on Android default to an empty instance
			return new JarResolverImpl();
#endif

			// bail out with an empty instance if the PlayServicesSupport class isnt available
			var playServicesSupport = Google.VersionHandler.FindClass( "Google.JarResolver", "Google.JarResolver.PlayServicesSupport" );
			if( playServicesSupport == null )
				return new JarResolverImpl();

			// create a live instance of the PlayServicesSupport class and return a live JarResolverImpl wrapping it
			var svcSupport = Google.VersionHandler.InvokeStaticMethod( playServicesSupport, "CreateInstance",
				new object[] {
				clientName,
				EditorPrefs.GetString( "AndroidSdkRoot" ),
				"ProjectSettings"
			} );

			return new JarResolverImpl( svcSupport );
		}
	}
}

Gradle failed to fetch dependencies.

Gradle failed to fetch dependencies.

Failed to run 'Temp\PlayServicesResolverGradle\gradlew.bat -b Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle "-PANDROID_HOME=E:/kunal/sdk" "-PTARGET_DIR=E:\VikasJha\Office Project\Unity Projects\Ludo Projects\FirebaseDemo\Assets\Plugins\Android" "-PMAVEN_REPOS=file:///E:/VikasJha/Office Project/Unity Projects/Ludo Projects/FirebaseDemo/Assets/Firebase/m2repository" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-base:11.2.0;com.google.firebase:firebase-common:11.2.0;com.google.firebase:firebase-core:11.2.0;com.google.firebase:firebase-app-unity:4.1.0;com.google.firebase:firebase-auth:11.2.0;com.google.firebase:firebase-auth-unity:4.1.0"'
stdout:
Starting a Gradle Daemon, 18 busy Daemons could not be reused, use --status for details

stderr:

FAILURE: Build failed with an exception.

  • What went wrong:
    java.io.IOException: Unable to establish loopback connection

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

exit code: 1

UnityEngine.Debug:LogError(Object)
GooglePlayServices.PlayServicesResolver:LogDelegate(String, LogLevel)
Google.JarResolver.PlayServicesSupport:Log(String, LogLevel, Boolean)
GooglePlayServices.c__AnonStorey14:<>m__20(Result)
GooglePlayServices.c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

resolution exception with play-services-measurement

So I wrote my own class to update the play services measurement and I'm getting this error:

Google.JarResolver.ResolutionException: Cannot resolve com.google.android.gms:play-services-measurement:10.2.0()
  at Google.JarResolver.PlayServicesSupport.ResolveDependencies (Boolean useLatest, System.Collections.Generic.Dictionary`2 dependencyMap, System.String destDirectory, Google.JarResolver.ExplodeAar explodeAar) [0x00000] in <filename unknown>:0 
  at Google.JarResolver.PlayServicesSupport.ResolveDependencies (Boolean useLatest, System.String destDirectory, Google.JarResolver.ExplodeAar explodeAar) [0x00000] in <filename unknown>:0 
  at GooglePlayServices.ResolverVer1_1.DoResolutionNoAndroidPackageChecks (Google.JarResolver.PlayServicesSupport svcSupport, System.String destinationDirectory, Google.JarResolver.OverwriteConfirmation handleOverwriteConfirmation) [0x00000] in <filename unknown>:0 
UnityEngine.Debug:LogError(Object)
GooglePlayServices.ResolverVer1_1:DoResolutionNoAndroidPackageChecks(PlayServicesSupport, String, OverwriteConfirmation)
GooglePlayServices.<DoResolution>c__AnonStorey1:<>m__0()
GooglePlayServices.ResolverVer1_1:DoResolution(PlayServicesSupport, String, OverwriteConfirmation, Action)
GooglePlayServices.PlayServicesResolver:Resolve(Action)
GooglePlayServices.PlayServicesResolver:MenuResolve()

I currently have 8.4.0, and I need to update this to the latest version so I can build my project. I can't seem to figure out why it's throwing this error or what it can't resolve specifically.

This is what I have in my class to have measurement up to date:

Type playServicesSupport = Google.VersionHandler.FindClass("Google.JarResolver", "Google.JarResolver.PlayServicesSupport");
if (playServicesSupport == null) return;

object svcSupport = Google.VersionHandler.InvokeStaticMethod(
	playServicesSupport, "CreateInstance",
	new object[]
	{
		"GooglePlayUnity",
		EditorPrefs.GetString("AndroidSdkRoot"),
		"ProjectSettings"
	}
);
		
Google.VersionHandler.InvokeInstanceMethod(
	svcSupport, "DependOn",
	new object[]
	{
		"com.google.android.gms",
		"play-services-measurement",
		"LATEST"
	},
	namedArgs: new Dictionary<string, object>()
	{
		{
			"packageIds", new string[]
			{
				"extra-google-m2repository",
				"extra-android-m2repository"
			}
		}
	}
);

Resolver doesn't work with Unity

Does that plugin really work with unity 4.6.8?
I have a problem. After importing unitypackage with jar resolver I'm see UnityEditor crash. I can't even open my project. But if I remove folder with resolver from project, all works fine.

Here some log:

Platform assembly: D:\programs\Unity4\Editor\Data\Managed\Mono.Cecil.dll (this message is harmless)
Platform assembly: D:\programs\Unity4\Editor\Data\Mono\lib\mono\2.0\UnityScript.dll (this message is harmless)
Platform assembly: D:\programs\Unity4\Editor\Data\Managed\ICSharpCode.NRefactory.dll (this message is harmless)
Platform assembly: D:\programs\Unity4\Editor\Data\Mono\lib\mono\2.0\System.Xml.Linq.dll (this message is harmless)
Crash!!!
SymInit: Symbol-SearchPath: 'D:/programs/Unity4/Editor/Data/MonoEmbedRuntime;.;D:\work\plugins\UnityDemo\unity4;D:\programs\Unity4\Editor;C:\Windows;C:\Windows\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'Asus'
OS-Version: 10.0.10586 () 0x100-0x1```

Crashes Unity 5.5+

Hi unity-jar-resolver team,

Starting with Unity 5.5 (beta currently) there is no 11th BuildTarget (XBOX369), as result Unity crashes as soon as you import Play Services Resolver.

If you could fix it fast, it would be awesome.

Thanks in advance,
Yuriy.

Crashes Unity 5.0

This is a similar issue as Issue #16.

Unity 5.0 crashes due to there not being a build target 35.

image

Happens on start-up of Unity, the second time I open a project. The exception is the first time I open a project. For example if I delete the Library folder and open the project, Unity will regenerate the Library and then open fine. But if I then close Unity and reopen the project, I get the error.

Downloaded libraries are not being removed

Using version 1.2.41.0 downloaded assets are not being removed from the Assets/Plugins/Android folder once their declarations have been removed from a script and the Editor re-opened. I have also tried to use Resolve Client Jars option to no avail.

Changing one of the Android settings (for example Prebuild With Gradle) does cause the assets to be cleared out.

Can't build for Android with error "CommandInvokationFailure: Unable to convert classes into dex format."

Hi, I'm using this for my projects, and that's really good for many google services.
When I used v1.2.35, everything works well. But, in new versions I can't build for Android.
I need facebook and google signin functionality in my app so added FB SDK and some small plugins with this plugin.
Cause of that, I get an error for android build as following.

`CommandInvokationFailure: Unable to convert classes into dex format.
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Volumes/DATA/SDK/25.2.2(for 5.5.1f1)/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity_2017.1.0f3/PlaybackEngines/AndroidPlayer/Tools/sdktools.jar" -

stderr[

trouble writing output: Too many field references: 66848; max is 65536.
You may try using --multi-dex option.
References by package:
3 android.accounts
25 android.app
14 android.arch.core.internal
2282 android.arch.lifecycle
1 android.content
36 android.content.pm
10 android.content.res
3 android.database
47 android.graphics
2 android.media
1 android.media.browse
2 android.net
6 android.net.wifi
21 android.os
3 android.print
13 android.support.annotation
2257 android.support.compat
2257 android.support.coreui
2257 android.support.coreutils
2359 android.support.customtabs
2257 android.support.design
106 android.support.design.internal
655 android.support.design.widget
2257 android.support.fragment
2463 android.support.graphics.drawable
2257 android.support.graphics.drawable.animated
2257 android.support.mediacompat
2637 android.support.transition
2257 android.support.v4
13 android.support.v4.accessibilityservice
943 android.support.v4.app
113 android.support.v4.content
13 android.support.v4.content.pm
16 android.support.v4.content.res
50 android.support.v4.graphics
57 android.support.v4.graphics.drawable
4 android.support.v4.hardware.display
12 android.support.v4.hardware.fingerprint
11 android.support.v4.internal.view
428 android.support.v4.media
8 android.support.v4.media.app
378 android.support.v4.media.session
7 android.support.v4.net
37 android.support.v4.os
52 android.support.v4.print
98 android.support.v4.provider
54 android.support.v4.text
6 android.support.v4.text.util
120 android.support.v4.util
412 android.support.v4.view
126 android.support.v4.view.accessibility
8 android.support.v4.view.animation
478 android.support.v4.widget
399 android.support.v7.app
2257 android.support.v7.appcompat
2257 android.support.v7.cardview
8 android.support.v7.content.res
18 android.support.v7.graphics.drawable
2257 android.support.v7.recyclerview
1 android.support.v7.text
124 android.support.v7.util
85 android.support.v7.view
270 android.support.v7.view.menu
1585 android.support.v7.widget
87 android.support.v7.widget.helper
1 android.support.v7.widget.util
1 android.system
6 android.text
1 android.text.util
13 android.util
26 android.view
8 android.view.accessibility
1 android.view.inputmethod
15 android.widget
2 bitter.jnibridge
158 bolts
2662 com.facebook
2257 com.facebook.android
170 com.facebook.appevents
43 com.facebook.appevents.internal
46 com.facebook.applinks
9 com.facebook.devicerequests.internal
574 com.facebook.internal
190 com.facebook.login
81 com.facebook.login.widget
32 com.facebook.messenger
43 com.facebook.places
102 com.facebook.places.internal
70 com.facebook.places.model
51 com.facebook.share
360 com.facebook.share.internal
114 com.facebook.share.model
124 com.facebook.share.widget
53 com.facebook.unity
2251 com.google.android.gms
20 com.google.android.gms.actions
19 com.google.android.gms.ads.identifier
2304 com.google.android.gms.auth
5 com.google.android.gms.auth.account
2272 com.google.android.gms.auth.api
68 com.google.android.gms.auth.api.accounttransfer
96 com.google.android.gms.auth.api.credentials
6 com.google.android.gms.auth.api.phone
37 com.google.android.gms.auth.api.proxy
50 com.google.android.gms.auth.api.signin
30 com.google.android.gms.auth.api.signin.internal
2251 com.google.android.gms.base
102 com.google.android.gms.common
98 com.google.android.gms.common.api
336 com.google.android.gms.common.api.internal
41 com.google.android.gms.common.data
44 com.google.android.gms.common.images
160 com.google.android.gms.common.internal
35 com.google.android.gms.common.stats
27 com.google.android.gms.common.util
25 com.google.android.gms.dynamic
20 com.google.android.gms.dynamite
2 com.google.android.gms.dynamite.descriptors.com.google.android.gms.flags
16 com.google.android.gms.flags.impl
3 com.google.android.gms.iid
660 com.google.android.gms.internal
5 com.google.android.gms.location.places
6 com.google.android.gms.security
2299 com.google.android.gms.tasks
23 com.google.firebase.iid
2251 com.rener.trix
205 com.unity3d.player
2276 in.locomotion.plugins.login
11 java.lang
11 java.lang.annotation
2 java.nio
1 java.nio.channels
6 java.util
2 java.util.concurrent
1 java.util.logging
20 org.fmod
1 org.json
]`

I have to add twitter signin funcationality, too. But haven't any solution just now.
According to my research, unity doesn't support multi-dex build yet.
So if possible, hope to make a choosable library interface (not the auto resolving all libraries) or at least reduce the library counts, because there are too many resolved libraries for only google signin.
Any suggestion will be welcome!
Thanks for your read.

Resolver improperly handles play-services-basement

Hey all,

I'm working on a project that with a plugin utilizes your resolver for grabbing the appropriate libs from Google Play. Problem is this: Google distributes a library which seems like it's undocumented called "play-services-basement". From what I could gather with some Google-Fu, this is either an extension of play-services-base or a minimal version of base that is required for using certain services libs. Either way, it's required for the ad networks we're working with, as it seems to contain a class called "GooglePlayServicesUtil" which the advertising libraries use to get advertising IDs.

Your resolver removes copies of this file as part of resolving the needed JARs, which has been breaking our app. Some sites call basement a dependency of base, so I'm confused why it wouldn't be included whenever base is included.

Additionally, the resolver does not even seem to be aware of the existence of basement. If I try to force an import by requesting it by name using code like:

var svcSupport = PlayServicesSupport.CreateInstance( PluginName, EditorPrefs.GetString( "AndroidSdkRoot" ), "ProjectSettings" );
svcSupport.DependOn( "com.google.android.gms", "play-services-basement", "8.4+" );

the resolver does not indicate an error has occurred, but does not add the library and will remove it from my project if it is there.

If I'm totally misinformed about what basement is, then I apologize, but it certainly seems like it doesn't collide with any other of the services libs and is an integral part of Play Services that people depend on. Please do let me know what should be done here if I'm mistaken about how to use these libraries.

Problem with Google Play Services 10.2.4

There seem to be a problem with 10.2.4 - specifying e.g. LATEST play-services-ads causes the error

Google.JarResolver.ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-ads-lite:[10.2.4]

(note the extra brackets around version string)

Examination of *.pom dependency files from Android SDK reveal that 10.2.4 files indeed include those extra problematic brackets.

Conflict: play-services-base-9.6.1 vs. play-services-measurement-8.4.0

When Jar Resolver resolves both play-services-base-9.6.1.aar and play-services-measurement-8.4.0/ (aar exploded as folder), then build fails with conflict:

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
...
stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzpz;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzqa;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzqa$zza;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzqb;
4 errors; aborting
]

Unity 5.3.6p6 on Windows 10 Pro targeting Android. Latest Android SDK installed with all components updated via Android SDK Manager.

Gradle Prebuild fails

I get "Resolution failed." when trying to Resolve Jars after enabling "Prebuild with Gradle". Any ideas how I can resolve this? I'm way over 64k references, so I need to strip the unused and was hoping prebuilding with gradle could do that.

Heres the error from Console

Error somewhere in the process of creating the gradle build, executing it, and copying the outputs.
This will break dependency resolution and your build will not run.
See the output below for possible gradle build errors. The most likely cases are: an invalid bundleID (which you can correct in the Android Player Settings), or a failure to determine the Android SDK platform and build tools verison (you can verify that you have a valid android SDK path in the Unity preferences.
If you're not able to diagnose the error, please report a bug at: https://github.com/googlesamples/unity-jar-resolver/issuesA possible work-around is to turn off the "Gradle Prebuild" from the Jar Resolver Settings.

Error (-1):
Traceback (most recent call last):
  File "<string>", line 468, in <module>
  File "<string>", line 459, in main
  File "<string>", line 446, in process_args
  File "json\__init__.py", line 338, in loads
  File "json\decoder.py", line 366, in decode
  File "json\decoder.py", line 382, in raw_decode
ValueError: Invalid \escape: line 24 column 12 (char 863)
generate_gradle_prebuild returned -1

UnityEngine.Debug:LogError(Object)
GooglePlayServices.<RunGenGradleScript>c__AnonStorey0:<>m__0(Result)
GooglePlayServices.ProgressReporter:Update(CommandLineDialog)
GooglePlayServices.CommandLineDialog:Update()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

Force resolving to certain version

Is there any way to resolve jars to a certain version by setting it somehow in dependencies.
If I set version to "9.8.0" it still resolves jars to latest versions (10.0.1).

NullReferenceException with 1.2.19.0

Hi,

Due to #47 I had to update Play Services Resolver. Now it works, but all the time logs the exception in Unity Console:

NullReferenceException: Object reference not set to an instance of an object
GooglePlayServices.ResolverVer1_1.AarPathToPackageName (System.String aarPath)
GooglePlayServices.ResolverVer1_1.FindAarExplodeDataEntry (System.String aarPath)
GooglePlayServices.ResolverVer1_1.ShouldExplode (System.String aarPath)
GooglePlayServices.ResolverVer1_1.ShouldReplaceDependency (Google.JarResolver.Dependency oldDependency, Google.JarResolver.Dependency newDependency)
GooglePlayServices.PlayServicesResolver.m__C (Google.JarResolver.Dependency oldDependency, Google.JarResolver.Dependency newDependency)
Google.JarResolver.PlayServicesSupport.CopyDependencies (System.Collections.Generic.Dictionary`2 dependencies, System.String destDirectory, Google.JarResolver.OverwriteConfirmation confirmer)
GooglePlayServices.ResolverVer1_1.DoResolutionNoAndroidPackageChecks (Google.JarResolver.PlayServicesSupport svcSupport, System.String destinationDirectory, Google.JarResolver.OverwriteConfirmation handleOverwriteConfirmation)
GooglePlayServices.ResolverVer1_1+c__AnonStorey8.<>m__10 ()
GooglePlayServices.ResolverVer1_1.DoResolution (Google.JarResolver.PlayServicesSupport svcSupport, System.String destinationDirectory, Google.JarResolver.OverwriteConfirmation handleOverwriteConfirmation, System.Action resolutionComplete)
GooglePlayServices.PlayServicesResolver.Resolve (System.Action resolutionComplete)
GooglePlayServices.PlayServicesResolver.AutoResolve ()
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:249)

Resolver 1.2.19.0, Unity 5.6, macOS.

Thank you for any help with it,
Yuriy

The name `Google' does not exist in the current context

Hi,
I've succesfully added the play-services-resolver-1.2.6.0.unitypackage in my unity project and copy paste the sample files in my script folder, but it won't build cause of :

Assets/Scripts/SampleDependencies.cs(95,5): error CS0103: The name `Google' does not exist in the current context

What I've missed?

Regards,

AndroidManifest.xml:23: Tag <provider> attribute authorities has invalid character '$'.

Hi,

I have a source code with ResolverVer1_1, and I noticed it gives me this error.

AndroidManifest.xml:23: Tag attribute authorities has invalid character '$'.

I checked the staging manifest file while unity was building and I noticed this line.

<provider android:authorities="${applicationId}.firebaseinitprovider" android:exported="false" android:initOrder="100" android:name="com.google.firebase.provider.FirebaseInitProvider" />

I updated to version 1.2, but the problem persist.

Your help is greatly appreciated.

Keep library

The jar-resolver keeps deleting the belvedere library (https://github.com/zendesk/belvedere) that i copied into the Plugins/Android folder. The first time it builds it only explodes it and deletes it on the second build. Is there a ways to specifically forbid the jar-resolver to do this?
The jar-resolver is called only by the AppDeps and the MessagingDeps of the Untiy Firebase plugin.

play-services-measurement provider ${applicationid} not being replaced

AndroidManifest.xml:36: Tag <provider> attribute authorities has invalid character '$'.

The docs mention this specifically but upon building the project the ${} is not replaced by the application bundle id.

I have no clue how to fix this. I know I can unpack the AAR file and adjust the manifest but I rather not. Any idea why this might happen?

Using unity 5.2.3 and the latest jar resolver.

4.6.8 not receiving any AAR packs

According to the docs 4.6.8 and up are supported, but I don't see any AAR packs being imported nor are they exploded/unpacked.

Any idea?

iOS Resolve Dependencies Menu Option

Hello, is there a plan to add a method and or menu option to explicitly resolve the cocoapod dependencies as you currently can with Android (GooglePlayServices.PlayServicesResolver.MenuResolve())? I ask because I'm trying to build a plugin that allows dependencies to be switched in and out from the editor, but I can't find a way of removing pods without restarting the editor.
Thanks.

Released DLLs file names should only change with major versions

File names of released DLLs change with each version which creates defined multiple times errors when app developers add more than one Unity plugin that includes different versions of this library.

I suggest the release .unitypackage contain v1 instead of v1.2.9.0 as part of their containing file names. Example, change Google.JarResolver_v1.2.9.0.dll to Google.JarResolver_v1.dll.

Misdetecting library update

Hi,

It permanently misdetects "support-annotations-24.0.0-alpha2" library as updated:

Android Jar Dependencies
Remove or replace support-annotations-24.0.0 version alpha2 with version 24.0.0-alpha2?

I suppose, the reason is "-" in a version (not just 24.0.0, but 24.0.0-alpha2).

Here is my dependencies initialization:

PlayServicesSupport playServicesSupport = PlayServicesSupport.CreateInstance(m_pluginName, EditorPrefs.GetString("AndroidSdkRoot"), "ProjectSettings");
playServicesSupport.DependOn("com.android.support", "support-v4", "+");
playServicesSupport.DependOn("com.google.android.gms", "play-services-gcm", "+");

Thank you!

JarResolver 1.2.14 throws exceptions with Unity 5.5

It looks like it is looking for PlayerSettings.applicationIdentifier - but this was added in 5.6 as far as I know. 5.5 should be using PlayerSettings.bundleIdentifier.

I get this error when using Unity
MissingMethodException: Method not found: 'UnityEditor.PlayerSettings.get_applicationIdentifier'.
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for GooglePlayServices.PlayServicesResolver
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (RuntimeTypeHandle type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.CompilerServices/RuntimeHelpers.cs:101)
UnityEditor.EditorAssemblies.ProcessEditorInitializeOnLoad (System.Type type) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:130)

com.google.android.gms.drive

I see it adds few aars by default

Method count
com.google.android.gms.drive: 1731
com.google.android.gms.nearby: 1614

and other few. Are those libraries used by default i removed drive and build succeed. Any explanation or a way to get rid of these library and keeping the auto sync feature on

Reduce log spam

I'm getting the following log messages everytime I start Unity:

Resolver version is now: 10101
Resolver version is now: 10102
Registering resolver version 1.2.0
Resolver version is now: 10102

Please add an option to disable these log messages.

Is generate_gradle_prebuild.exe necessary to import to projects?

Hi, I am adding google play service for unity 0.9.37 on my unity 5.5 projects, but meets some errors when setting up, so I used the lastest 0.9.38a, it works. and I noticed the package size is much large than previous versions, the generate_gradle_prebuild.exe and other files were introduced, I just wanna know the uses of these files? thanks.

firebase-core-9.6.1 .aar file build failure

error

The aar file generated by the resolver for firebase-core 9.6.1 appear to be missing the class.jar file associated with it; that, or unity is expecting a classes.jar file, where none exists.

Cleaner UI for choosing resolution action

When there are many jars being resolved, the popups that ask users to choose to keep or to use the latest version gets overwhelming.

A better UI might be one that list all the libraries being resolved and lets the user decide on what to do.

image

Google.JarResolver.ResolutionException: Cannot resolve com.android.support:support-v7:23.4.0() at Google.JarResolver.PlayServicesSupport.ResolveDependencies (Boolean useLatest) [0x00000] in <filename unknown>:0

Hi,
I'm just trying to add android support to a unity pluggin but when the dependency script starts I'm having this output in the console :
Google.JarResolver.ResolutionException: Cannot resolve com.android.support:support-v7:23.4.0() at Google.JarResolver.PlayServicesSupport.ResolveDependencies (Boolean useLatest) [0x00000] in <filename unknown>:0 at GooglePlayServices.ResolverVer1_1.DoResolutionNoAndroidPackageChecks (Google.JarResolver.PlayServicesSupport svcSupport, System.String destinationDirectory, Google.JarResolver.OverwriteConfirmation handleOverwriteConfirmation) [0x00000] in <filename unknown>:0 UnityEngine.Debug:LogError(Object) GooglePlayServices.ResolverVer1_1:DoResolutionNoAndroidPackageChecks(PlayServicesSupport, String, OverwriteConfirmation) GooglePlayServices.<DoResolution>c__AnonStorey5:<>m__8() GooglePlayServices.<DoResolution>c__AnonStorey6:<>m__D(Result) GooglePlayServices.ProgressReporter:Update(CommandLineDialog) GooglePlayServices.CommandLineDialog:Update() UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I'm not even asking for 23.4.0 I'm asking for 25.0.1, any idea?

Regards,

Android Prebuild with Gradle

Hi,

Im currently working on a large project with a few plugins. After adding the GoogleMobileAds plugin to the project it hits the lovely dex limit so i enabled the "Prebuild with Gradle"(awesome work btw). But i keep getting this error when i use the "Force Resolve" functionality.

Specs:
macOS Sierra 10.12.6
Unity 2017.1.1f1
Min API level: 16
Max API level: Auto
Installed Android SDK 25 with build tools 25.0.3.
Checked the Package Name(bundleID) in the Android Player Settings.

Error somewhere in the process of creating the gradle build, executing it, and copying the outputs.
This will break dependency resolution and your build will not run.
See the output below for possible gradle build errors. The most likely cases are: an invalid bundleID (which you can correct in the Android Player Settings), or a failure to determine the Android SDK platform and build tools verison (you can verify that you have a valid android SDK path in the Unity preferences.
If you're not able to diagnose the error, please report a bug at: https://github.com/googlesamples/unity-jar-resolver/issuesA possible work-around is to turn off the "Gradle Prebuild" from the Jar Resolver Settings.

Error (1):
Traceback (most recent call last):
File "Temp/PlayServicesResolverGradlePrebuild/generate_gradle_prebuild.py", line 476, in
sys.exit(main())
File "Temp/PlayServicesResolverGradlePrebuild/generate_gradle_prebuild.py", line 468, in main
generate_gradle_build(build_path, jsobj)
File "Temp/PlayServicesResolverGradlePrebuild/generate_gradle_prebuild.py", line 215, in generate_gradle_build
ignore=shutil.ignore_patterns("*.meta"))
File "Temp/PlayServicesResolverGradlePrebuild/generate_gradle_prebuild.py", line 93, in merge_dir_tree
shutil.copy2(s, d)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 130, in copy2
copyfile(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: u'/Users/jur/Documents/AppName/Temp/GenGradle/m2repository/.DS_Store'

UnityEngine.Debug:LogError(Object)
GooglePlayServices.c__AnonStoreyE:<>m__11(Result)
GooglePlayServices.ProgressReporter:Update(CommandLineDialog)
GooglePlayServices.CommandLineDialog:Update()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I can't see the m2repository in de Temp folder is it missing or does it get removed after something fails?

Kind regards,

Jur

Dependencies are ignored

I think I found a problem.
In case if I add only my plugin to a project all works fine. But if I add two plugins with jar resolver (one of them is mine), I can't find my dependencies. I've tried to add log output to RegisterDependencies method and I know that it has been called and finished.
I didn't see any other log output.
Clearing temp files, library folder, and project settings don't help.

Here is my dependencies file:
https://gist.github.com/Tamplier/d56300c846ee62879c85125bdf711de3

To reproduce the bug you can add GooglePlayGamesPlugin (version 0.9.38a):
https://github.com/playgameservices/play-games-plugin-for-unity

I work in Unity 5.6.1f1 at the moment.

Any way to disable the auto resolver from code?

I'm working on a tool to manage build configurations for different Android stores. This automatically removes certain plugins.

However, it doesn't seem like the resolver cleans up after itself, leaving unwanted jars and aar files in my project, even if the plugins that needed them are gone, so I'm trying to remove these files from code. The problem is that when I delete the plugins and the unwanted aar files (in that order), the resolver restores them anyway. It seems like it doesn't know yet that I deleted the plugins that need these files.

So I'd like to turn off the resolver temporarily while my scripts do their thing, and enable it again later, so the resolver doesn't add libraries that are no longer needed. Is there any way to do this?

Thanks!

Google.JarResolver.ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-gcm

Hi I got this error in my Unity 3D project

Google.JarResolver.ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-gcm:9+
at Google.JarResolver.PlayServicesSupport.DependOn (System.String group, System.String artifact, System.String version) [0x00000] in :0
at OneSignalEditorScriptAndroid.addGMSLibrary () [0x00033] in D:\Tatweer\Foodak\Mobile\Unity Project\Assets\OneSignal\Editor\OneSignalEditorScript.cs:51
at OneSignalEditorScriptAndroid..cctor () [0x0001a] in D:\Tatweer\Foodak\Mobile\Unity Project\Assets\OneSignal\Editor\OneSignalEditorScript.cs:43
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()

I update the Libraries from Andriod SDK Manager but I still got this problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.