Conflict between Asset's Newtonsoft and PackageManager's Newtonsoft

Hey guys,

(Unity 2019.3.4f1)
So i want to start my new project and i wanted to use Entities in it.

I have already installed it using the packagemanager and all the requirements needed and everything is fine, i have created myself a popup system that i exported to a package and i imported it to the new project, the package contains the Newtonsoft.Json.dll plugin and i get an error that says:
“PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included for the current platform. Only one assembly with the same name is allowed per platform”.

From what i see, Entities are using “Platforms” which contains Newtonsoft Json, therefore the issue lays there where now i have 2 assemblies with the same name as mentioned in the issues above which also causes scripts not to compile such as TextMeshPro and UnityEngine.UI.

If i am removing the Newtonsoft Json dlls from my assets folder then my popup system scripts that use it will not compile (), if i am removing the Newtonsoft Json from the Library/PackageCache of the project it will compile but the next time i open the project unity will re-add that and repeat the issue.

If i remove Entities completely everything works fine with no issue but i want to use Entities in this project.

One of the “solutions” i came across is renaming the dlls in the Assets folder to have a different name than the ones that came from the PackageManager but i don’t think its something that should be done.

What do i need to do to solve this issue?
Would appreciate any help with this problem.

2 Likes

I have the same problem with a third party asset. Does anyone have an idea what to do?

Hey,

Have you tried updating Entities package to its latest available version?

Cheers,

Supi

yes i did, i even had to downgrade Visual Studio Code Editor to 1.1.3 from 1.1.4 because it was causing UnityEngine.UI to not compile and become missing.

but that’s not the issue, the Entities package is not where the problem is, Entities are using the package called “Platforms” and one of the dependencies of that package is “Nuget Newtonsoft-Json” which where the issue begins, by having that package AND your own Newtonsoft-Json DLL sitting in assets causing the conflict.

there are a few approaches but not all gives a solution:

  1. by renaming the DLL sitting in assets does stop the conflict and makes everything work out (SOLUTION)
  2. by removing the DLL sitting in assets causing everything that uses it (user made scripts) not to compile (NOT A SOLUTION)
  3. by deleting the folder of the newtonsoft from your project’s Library/PackageCache will stop the conflict but will return once unity is closed and reopens (TEMPORARY SOLUTION)
1 Like

Try turning it off and on again.

the worst is that you can’t refference used newtonsoft assembly, because it’s in package cache, and its is “only for internal use” but conflicts we’re the ones getting.

https://docs.unity3d.com/Packages/com.unity.nuget.newtonsoft-json@1.1/manual/index.html

2 Likes

I’m encountering the same issue. I created a package that I use in multiple projects that depends on Newtonsoft Json. As far as I can tell, there’s no way to use it in a package that also uses Entities. And yes, I’m on the latest version of Entites.

Like i said earlier:
One of the “solutions” i came across is renaming the dlls in the Assets folder to have a different name than the ones that came from the PackageManager but i don’t think its something that should be done.

that will let you work with entites but like i said i dont think its something that should be done because perhaps its an issue from unity for not spotting an issue like this can raise.

I wasn’t able to get that solution to work. Specifically, I renamed Newtonsoft.Json.dll → Newtonsoft.Json2.dll in the Assemblies/Windows directory. I got the same “multiple precompiled assemblies” error after importing the Entities package. Is there something else you did to get that to work?

i renamed all under Assemblies, not only the windows directory one.
notice it says “PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included for the current platform. Only one assembly with the same name is allowed per platform”,
that means ANY dll with that name will cause this conflict therefore i suggest to rename all the Newtonsoft.Json.dll
under Assemblies folder in the plugin.

I’ll give that a try, thanks!

And what to do, when you’re using plugin that came from 3rd party and its dependant on Newtonsoft.Json, and you can’t change assembly name since then plugin throws errors that he can’t find dll and your plugin might crash during runtime?

1 Like

I am yet to encounter such issue since i am not really using 3rd party plugins at least atm, especially not ones that use Newtonsoft.Json, so far everything in my project is my own development (regardless of the system if its popups, assetbundles, localization and so on), therefore i have no answer to that yet. sorry :frowning:

I was having a similar issue and it was driving me crazy. It all started after trying to test out ECS. I had another Newtonsoft JSON package installed from 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 and started to get the “Multiple precompiled assemblies with the same name Newtonsoft.Json.dll” error when compiling. If you look in “Library > PackageCache” you will most likely see a folder called “com.unity.nuget.newtonsoft-json@1.1.2” or something similar. Inside that folder is a README.md which I looked at. It had instructions for using the package. I replaced my jilleJr package in the manifest.json with “com.unity.nuget.newtonsoft-json”: “2.0.0-preview” and everything is compiling again. It appears that Unity is now including Newtonsoft JSON in certain cases. This fixed my issue. Maybe it will help you too…

6 Likes

I’m having the same problem

Our team is well aware that this is still a problem. The good news is that the team know of a great way to address this but right now, this is no ETA that they can provide at present.

Great News Thank you!
But when do get the great way?

I’m not really privy to precisely what the method would be but it’s more of a multi-team effort thing that is needed for the proposed idea. It’s incredibly early stages but something the team thinks they can tackle. We’ll be sure to share more news when we have updates.

1 Like

I was about to write that this issue was a “Showstopper” for my project until I read this comment. Thank you!!

Also with the workaround by @christophera_unity in here: https://discussions.unity.com/t/779946/4

This fixed almos all my errors. Some other was solved by modifying the manifest but the root problem is was the same, having 2 Newtonsoft dll in the project and then try to repleace one of them.

I was using this solution in my project https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347

I just never can’t be mad with Unity but please fix this or give us another “more friendly” workaround or just the chance to select the .json NET solution of our choise.

@UnityMaru , @christophera_unity .

2 Likes

Any update about this issue? 3 months since last comment. Do you have yet any ETA? Is shocking how this setback let you totally stuck.

Any update on this know breaking issue?