question

Yoshitaka Kimisaki avatar image
Yoshitaka Kimisaki asked

,PlayFab Unity SDK does not work on Android/iOS devices.

,

Hello.

At first, I created a simple project with PlayFab Unity SDK unitypackage, and I write a simple code used only LoginWithCustomID API.

Then I tried to build it as Windows/Android/iOS IL2CPP and run on each device.

It works perfectly on Unity Editor, but PocoJsonSerializerStrategy cause a NullReferenceException on IL2CPP platforms.

I checked PocoJsonSerializerStrategy.ConstructorCache is a empty dictionary.

As far as I know, type.GetConstructors on ReflectionUtils.GetConstructors returns an empty array because reflection don't work on IL2CPP.

```

System.NullReferenceException: Object reference not set to an instance of an object. at PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) [0x00000] in <00000000000000000000000000000000>:0 at PlayFab.Json.SimpleJsonInstance+PlayFabJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) [0x00000] in <00000000000000000000000000000000>:0 at PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json, System.Type type, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <00000000000000000000000000000000>:0 at PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (System.String json, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <00000000000000000000000000000000>:0 at PlayFab.PlayFabClientAPI+<LoginWithCustomIDAsync>d__88.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0

```

When I use PlayFab CSharp SDK, but it doesn't work on each devices too.

It doesn't use UnityWebRequest.

Do you have a way to use PlayFab on Unity Android/iOS?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Usually we implement Unity SDK instead of CSharp SDK in Unity project. Can you post the codes where this issue occurs?(please hide sensitive information). I have created an app with Android IL2CPP but cannot reproduce your issue, the login works well.

0 Likes 0 ·
Thomas LAURENT avatar image
Thomas LAURENT answered

For me it was the 'Managed Stripping Level' which was too high and stripped too much code in the build for Android.

Try this fix: In 'Project Settings > Player > Other Settings' when you are with a Scripting Backend set to 'IL2CPP' change the 'Managed Stripping Level' to 'Low' (others won't work).


In the next build the PocoJsonSerializerStrategy.DeserializeObject exception should be fixed.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

levet-jerome avatar image
levet-jerome answered

Hey there, same problem.
Did someone managed to fix this keeping Stripping level? (isolate which class is required and keep it with a link.xml file)

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Maor Cohen avatar image
Maor Cohen answered

I know it's an old issue, however maybe it's still relevant for some people.

I fixed the issue by changing the link.xml settings as follows:

Removed the following part:

   &lt;assembly fullname="Assembly-CSharp"&gt;
     &lt;namespace fullname="PlayFab.*" preserve="all"/&gt;
   &lt;/assembly&gt;

And added the following instead:

 &lt;assembly fullname="PlayFab" preserve="all"/&gt;

I would like to mention that in our project we have a dedicated assembly definition that is referencing the PlayFab assembly and that's why the fullname Assembly-CSharp was changed. I believe that the new setting should work also for the default project settings (= not having assembly definition at all) but I haven't tested it. If this still doesn't work for you try changing fullname="PlayFab" to fullname="Assembly-CSharp".

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.