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
https://github.com/jilleJr/Newtonsoft.Json-for-Unity
MIT License
1.16k stars 131 forks source link

Wrong dll for Android #5

Closed Merichbier closed 5 years ago

Merichbier commented 5 years ago

Source/destination types

    [Serializable]
    public class Config
    {
        public string Location;
        public PointOfInterest[] PointsOfInterest;

        public override string ToString()
        {
            return JsonConvert.SerializeObject(this);
        }
    }

Expected behavior

Installing the package through UI, building for Android and working Serialization/Deseralization

Seems the package include the wrong dll : It include the same dll as for the standalone image

Actual behavior

Just installed your package, building for Android and I have a PlatformNotSupportedException : Operation is not supported on this platform. at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod

Steps to reproduce

Create a new Unity Project in 2019.2.0f1, import the package through UI, using this class, we cannot deserealize the json

    [Serializable]
    public class Config
    {
        public string Location;
        public PointOfInterest[] PointsOfInterest;

        public override string ToString()
        {
            return JsonConvert.SerializeObject(this);
        }
    }
Merichbier commented 5 years ago

My bad I cried too quickly.. Fixed when setting API compatibility to 4.x

applejag commented 5 years ago

Missed this due to semester. But glad you found a solution! I'll add it as requirement in the installation guide.

Should be compatible with NET Standard 2.0 comparability setting though. (Well both actually...) I'll investigate.

For future reference, what package version were you using?

Merichbier commented 5 years ago

Hej I was using 12.0.1. It was for a project on iOS and Android, unfortunately we had a DLL not found error when compiling on iOS. Since it was my colleague who handle the mac build (don't have a mac myself..) I can't tell more about the bug, but it would be interessting just to look if reproducible with Unity 2019.2.1f on Mac with pretty much default settings (.net was set to 2.0 but even with 4.x didn't wanted to compile) Thanks for the interest =)

applejag commented 5 years ago

Right! So I think this is related to #3, with the fix being you have to update to 12.0.1-patch-001 in the manifest.json manually.

If you get any updates about the iOS build troubles then is it possible to forward them so I can implement them here as well? Neither I have access to Mac

Thank you for helping!

applejag commented 5 years ago

A temporary solution is to copy the folder /Library/PackageCache/jillejr.newtonsoft.json-for-unity.* folder into /Package/ (where the manifest.json lies), then remove it from the list in the manifest.json.

Doing so you can then edit the files in the package as they are no longer considered readonly

applejag commented 5 years ago

Did this resolve? @Merichbier ?

Will close soon for inactivity.