Hi everyone. I’m making an Android app using Unity 2022.3.16f. Part of my game involves serializing a save file to JSON to be sent to Firebase RT Database. For that, i’m using Newtonsoft JSON because the structure of my savefile makes JsonUtility.Stringify not work correctly.
When running the build on my Android device (Xiaomi Mi 9 SE, although i think the device model has no relation with the issue), it throws an error:
Currently the app is configured to use IL2CPP and .NET Framework.
Now, i have searched this a LOT before posting this, so here is every information i know regarding the issue.
Originally, it seems that Newtonsoft.Json package maintained by unity did not support AOT, which was required to run IL2CPP on Android. Many people suggested this package: GitHub - applejag/Newtonsoft.Json-for-Unity: Newtonsoft.Json (Json.NET) 10.0.3, 11.0.2, 12.0.3, & 13.0.1 for Unity IL2CPP builds, available via Unity Package Manager which was a fork of the Newtonsoft.Json that implemented AOT support that the Unity version did not have (This Stack Overflow link was my guide: c# - Newtonsoft.Json works in Unity Editor but not on mobile devices - Stack Overflow)
But as you can see in the repository, seems like it has been discontinuated since Unity absorbed it as its default package. I can state that i am already using this package, since this doc states that the latest Newtonsoft.Json package is 3.2.1: Newtonsoft Json Unity Package | Newtonsoft Json | 3.2.1
I can i assure that this version is the one installed on my project
However, this error still occurs, even though many places states that this version does have AOT support for IL2CPP.
I have tested changing the project compilation to Mono, and doing that makes it work correctly. Sadly i can’t keep on Mono since it only builds for ARMv7 and not for ARM64, which is required to publish on Google Play Store
Now, in the stackoverflow post, someone did mention something that i think is related to my issue, but no one has responded so i don’t know if this is a real issue

So, i need to make this serialization work on IL2CPP Android builds. To be honest, it doesn’t even have to be using Newtonsoft.Json, i just need a way to serialize/deserialize save files into JSON. If no one has a solution to the problem with Newtonsoft.Json, i’m accepting other library alternatives that can do that.
Another hypotesis i have i my head is that somehow there is another version of Newtonsoft.Json library installed in my project besides the 3.2.1 version, that somehow, c# is using instead of the most updated one, but i don’t know how to check if this is true, or how to remove other copies (It’s only a hypotesis, if it were true, i’d think it would give me errors on the console of “duplicate classes” or something like that, but those do not show up)


