- Home /
MissingMethodException in UNet matchmaking
Hello!
I've been playing around with the UNet service, specifically trying to implement the matchmaking for my little game prototype. I got to a point where I can reliably play using the matchmaking service and connect to/from the editor to/from a separate stand-alone client.
Then I decided to test it out on my android device (Lenovo P70-A) and for some reason, it didnt' work. So, I fired up the ADB and tried to inspect what was happening. This is the output from my device:
I/Unity (11519): MatchMakingClient ListMatches :https://mm.unet.unity3d.com/json/reply/ListMatchRequest I/Unity (11519): I/Unity (11519): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe bugBindings.gen.cpp Line: 37) I/Unity (11519): I/Unity (11519): MissingMethodException: Method not found: 'Default constructo r not found...ctor() of UnityEngine.Networking.Match.ListMatchResponse'. I/Unity (11519): at System.Activator.CreateInstance (System.Type type, Boole an nonPublic) [0x00000] in :0 I/Unity (11519): at System.Activator.CreateInstance (System.Type type) [0x00 000] in :0 I/Unity (11519): at System.Activator.CreateInstance[ListMatchResponse] () [0 x00000] in :0
The first line is output automatically by the matchmaking client, upon calling it in a method like this: _matchMaker.ListMatches(0, 20, string.Empty, OnMatchList);
OnMatchList is a callback that is called as soon as the matchlisting is complete (it's a coroutine). If it was working, the output would contain raw json response from the matchmaking service (probably for debug purposes). But instead, it outputs that.
Anyone has any idea, what is happening? I'm building the app for API Level 9 (2.3.1) and I'm using Unity Pro. I googled a bit and found out that some people have issues with the reachability of the service, but I have no such issues using editor or stand-alone client.
I already upgraded to the latest 5.3.5 version. I noticed in patch notes that there was another bug with the same exception, but in a different component. I hoped it was somewhat related, but it wasn't.
Thanks in advance!
Answer by Ewan K · May 26, 2016 at 01:06 PM
I accidentally figured it out.
It seems that Stripping Level set to other than "Disabled" causes the parameter-less constructor of the aforementioned struct (ListMatchResponse) to be stripped away and thus causing the exception.
Also, while testing it in a separate minimal project I used to send with a bugreport and trying to force the error/exception by changing the stripping level back to non-Disabled, I got a bit different exception.
So it seems that this issue is not exclusively related to matchmaking code.
tl;dr Changing stripping level to Disabled "fixes" the issue. Bug report has been sent.
Great answer, ran in to the same problem to and had no clue... they should have it mentioned in document!
Yes, that's a common problem when using certain thing only by reflection. Byte-code strippers try to figure out which members are in use by checking if it's used somewhere in the code. Since the actual constructor most likely isn't used anywhere in the code it will get stripped away. That's why the usage via reflection fails. Reflection calls can't be deteced by analysing the byte code.
Yes, i would also classify it as bug. Unity has to ensure that those things aren't stripped.