I have a "Shared" project where I share code between my client (unity) and my server (C# server)
Both projects require Newtonsoft.Json.dll
When I compile the Shared.dll and put it inside of Unity's Resources folder (so it's included in the build), I get this error :
PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included or the current platform. Only one assembly with the same name is allowed per platform. Assembly paths:
Assets/Resources/Shared/Newtonsoft.Json.dll
C:/Users/rotmg/Documents/GitHub/AG-LNL/AG-LNL-Client/Library/PackageCache/[email protected]/Runtime/Newtonsoft.Json.dll
I realise it's a conflict between Unity's dependency on Newtonsoft.Json and my Shared.dll's.
This answer :
https://answers.unity.com/questions/1697304/how-to-resolve-multiple-precompiled-assemblies-err.html
Says to use "merge all the dependencies into one .dll"
So I tried using Costura.Fody to build a single .dll that bundles all dependencies, but then I get an error saying that I should add references to the dependencies that Shared has. (NLog, BouncyCastle, etc.)
How can I resolve this conflict?
In my case after updating from Unity 2020.3.8f1 to 2020.3.17f1 and package com.unity.collab-proxy
from 1.3.9 to 1.7.1 it got dependency com.unity.nuget.newtonsoft-json
which was conflicting with my manually imported JsonDotNet package in Assets folder.
Removing my manually imported JsonDotNet package from Assets folder helped. After removing close Unity, delete folders YouProjectFolder\Library\PackageCache
and YouProjectFolder\Library\ScriptAssemblies
and restart Unity.
based on this answer: https://www.gitmemory.com/issue/juicycleff/flutter-unity-view-widget/414/859018825
best way is to import project without JsonDotNet folder or remove JsonDotNet folder before importing.
I got this issue after adding another package using Newtonsoft.Json.dll, causing a conflict. For me removing one of the duplicates resolved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With