Skip to content

[Bug] Building an Android project in Unity 2021.2.0b1 (beta) may cause a runtime exception in the Unity Editor when looking up GetApplicationIdentifier in UnityCompat.cs. #447

Closed
@patm1987

Description

@patm1987

[READ] For Firebase Unity SDK issues, please report to Firebase Unity Sample

Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021.2.0b1.3029
  • External Dependency Manager version: 1.2.162
  • Source you installed EDM4U: .unitypackage
  • Features in External Dependency Manager in use: Android Resolver
  • Plugins SDK in use: Google Play
  • Platform you are using the Unity editor on: Windows

[REQUIRED] Please describe the issue here:

After performing an Android build (and every time launching the editor after that build), Unity repeatedly logs:

AmbiguousMatchException: Ambiguous match found.
  at System.RuntimeType.GetMethodImplCommon (System.String name, System.Int32 genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConv, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00050] in <fd976842c3634855aba83404a44c7daa>:0 
  at System.RuntimeType.GetMethodImpl (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConv, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) [0x00000] in <fd976842c3634855aba83404a44c7daa>:0 
  at System.Type.GetMethod (System.String name, System.Reflection.BindingFlags bindingAttr) [0x0000e] in <fd976842c3634855aba83404a44c7daa>:0 
  at System.Type.GetMethod (System.String name) [0x00000] in <fd976842c3634855aba83404a44c7daa>:0 
  at GooglePlayServices.UnityCompat.GetUnity56AndAboveApplicationIdentifier (UnityEditor.BuildTarget buildTarget) [0x00000] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/UnityCompat.cs:446 
  at GooglePlayServices.UnityCompat.GetApplicationId (UnityEditor.BuildTarget buildTarget) [0x00000] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/UnityCompat.cs:500 
  at GooglePlayServices.PlayServicesResolver.GetAndroidApplicationId () [0x00000] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1041 
  at GooglePlayServices.PlayServicesResolver.<PollBundleId>m__36 () [0x00000] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1429 
  at GooglePlayServices.PlayServicesResolver+PropertyPoller`1[T].Poll (System.Func`1[TResult] getCurrentValue, GooglePlayServices.PlayServicesResolver+PropertyPoller`1+Changed[T] changed) [0x0002f] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:343 
  at GooglePlayServices.PlayServicesResolver.PollBundleId () [0x00000] in /Users/chkuang/Workspace/Git/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:1429 
  at UnityEditor.EditorApplication.Internal_CallUpdateFunctions () [0x00032] in <ca192453d8394227952a14f40675979e>:0 

The issue appears to be this line:

        var getApplicationIdentifierMethod =
            typeof(UnityEditor.PlayerSettings).GetMethod("GetApplicationIdentifier");

Further investigation reveals that Unity defines both:

public static string GetApplicationIdentifier(NamedBuildTarget buildTarget)

and

public static string GetApplicationIdentifier(BuildTargetGroup targetGroup)

The solution is likely to request the implementation of the method that takes a BuildTargetGroup to eliminate the conflicting name and allow this code to work:

      BuildTargetGroup buildTargetGroup = UnityCompat.ConvertBuildTargetToBuildTargetGroup(buildTarget);
      if (buildTargetGroup == BuildTargetGroup.Unknown)
        return (string) null;
      return method.Invoke((object) null, new object[1]
      {
        (object) buildTargetGroup
      }) as string;

Please answer the following, if applicable:

What's the issue repro rate? 100%

What happened? How can we make the problem occur?
Add a plugin that uses EDM4U to a Unity 2021.2.0b1 project. After building for Android, you should start to see these logs. Tested in both Firebase and with the Play plugin for Unity.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions