Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ambiguous Match found

Discussion in 'Unity Build Automation' started by CDF, May 26, 2017.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Hi, so I'm trying to integrate Firebase into Unity. The official SDK doesn't work with cloud build. So I've resorted to using these libraries:

    https://github.com/step-up-labs/firebase-database-dotnet
    https://github.com/step-up-labs/firebase-authentication-dotnet

    I'm targeting IOS.
    Using Unity 2017.1b6

    Now the above libraries don't work directly in 2017.1, I think because of some .NetStandard thing. Anyway... I cloned the repos, dumped the code in Unity, removed unnecessary classes etc.

    My test runs fun in the Editor. I can download my DB, all good. However, cloud build complains:

    Code (CSharp):
    1. 1890: [Unity] AmbiguousMatchException: Ambiguous match found.
    2. 1891: [Unity]   at UnityEditor.CloudBuild.UnityReflector.TryLoadMethodInfo (System.Reflection.Assembly assembly, System.String fullName, System.Reflection.BindingFlags flags, System.Reflection.MethodInfo& methodInfo, System.Type[] types) [0x0003d] in <2c89a24bfae14f1f8eba59b377c83874>:0
    3. 1892: [Unity]   at UnityEditor.CloudBuild.UnityReflector..cctor () [0x00185] in <2c89a24bfae14f1f8eba59b377c83874>:0
    4. 1893: [Unity] Rethrow as TypeInitializationException: The type initializer for 'UnityEditor.CloudBuild.UnityReflector' threw an exception.
    5. 1894: [Unity]   at UnityEditor.CloudBuild.Builder.DisableAutoLightbake () [0x00053] in <2c89a24bfae14f1f8eba59b377c83874>:0
    6. 1895: [Unity]   at UnityEditor.CloudBuild.Builder.Build () [0x00005] in <2c89a24bfae14f1f8eba59b377c83874>:0
    7. 1896: [Unity] executeMethod method UnityEditor.CloudBuild.Builder.Build threw exception.
    8. 1897: [Unity] Aborting batchmode due to failure:
    9. 1898: [Unity] executeMethod method UnityEditor.CloudBuild.Builder.Build threw exception.
    10. 1899:  ! Unity player export failed!
    I'm not sure why the exception is happening at "DisableAutoLightbake", but I'm assuming that's where it's coming from. Could there be some kindof conflict here? Because I'm dealing with 3rd party libraries, I can't exactly nail down where an Ambiguous method might exist.

    Even without adding any scenes to the build, I still get the errors. And I have all "Auto Bake Lights" off, even all light settings off

    Any ideas what might cause this? Or how I can track down an offending method, if any?

    I think I've aged 20 years in the last week trying to integrate Firebase into Unity for iOS. It is the single most painful experience as I developer I've ever had. Maybe if UCB had cocoapods it would be fine. But it doesn't and probably never will :(

    Appreciate any help I can get.
    Thanks.
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    This is what pain looks like:

    pain.png
    20 days ago my life was great. Since then, a deep decline.
    With a client build approaching, kinda getting a bit worried.

    Sorry, just need to rant a bit.
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Are you including anything related to cloud build in your project? for example - some DLL related to cloud build ?
     
  4. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    The only dll's that exist in the project are:

    Newtonsoft.Json and System.Net.Http (grabbed from the mono directory in Unity)
    Project compiles fine locally.
     
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    OK now that i read the error message again:
    executeMethod method UnityEditor.CloudBuild.Builder.Build threw exception

    Do you have 2 (or more) methods with the same name? which method is marked as pre-execute or post-execute step?
    From the stack trace it looks like they're using reflection to find that method and invoke it, but fail due to ambiguous match (more than one candidate method to run)
     
  6. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    I don't have any PostProcess script or any pre-execute or post-execute methods.
    There are indeed overloaded methods in the 3rd party library. Guess I'm gonna have to go through class by class, removing, committing, building until I find what class and what method is causing this.

    But I think there's something else going on here. I've built plenty of projects on Cloud Build that contain overloaded methods.

    If I had to guess, I think it's the System.Net.Http.dll or Newtonsoft.Json. There really isn't much to this test project, the C# is perfectly valid.

    Maybe it's a 2017 beta thing?
     
  7. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    I'm seeing this warning too:

    Code (CSharp):
    1. [Unity] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
     
  8. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Ok, something is terribly wrong with Cloud build.

    I have deleted every file (except my test script) from the project. Set library cache to none. Yet the same warnings occur above.

    I'm going to try creating a new repo and new cloud build project tomorrow. Maybe cloud build is holding on to some cached thing.

    Or the more likely reason: .Net 4.6 or Unity 2017.1 is currently not supported on Cloud build.
     
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Maybe they're aware of it. @dannyd is this a known issue at the moment ?
     
  10. SophiaC

    SophiaC

    Joined:
    Sep 6, 2016
    Posts:
    238
    Which version of Xcode are you using?

    - Sophia
     
  11. Arclight_TW

    Arclight_TW

    Joined:
    Feb 22, 2015
    Posts:
    1
  12. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    The cloud build compile is not getting to the xcode step. It's an issue with Unity, and I believe .Net 4.6

    To answer your question though, I'm targeting the latest supported version, which I think is 8.3.
     
  13. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Sorry for slow followup - ya .NET 4.6 in Unity 2017.1 is not currently supported in UCB. We're working on addressing that.
     
  14. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
  15. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Selecting .NET 4.6 in in Unity 2017.1 should now be working in UCB (and you should no longer see those "AmbiguousMatchException" errors).