Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Building on standalone causes plugin collision #3

Closed
applejag opened this issue Jul 24, 2019 · 15 comments · Fixed by #4
Closed

Building on standalone causes plugin collision #3

applejag opened this issue Jul 24, 2019 · 15 comments · Fixed by #4
Assignees
Labels
bug:builing Building in Unity fails due to bug bug Something isn't working

Comments

@applejag
Copy link
Owner

applejag commented Jul 24, 2019

Expected behavior

Building with and without IL2CPP on Windows will flip between using "Newtonsoft AOT" and "Newtonsoft Standalone" DLLs.

The define constraints should filter according to the constant ENABLE_IL2CPP.

Actual behavior

They collide as if both are supposed to be loaded. Build error in Unity:

Plugin 'Newtonsoft.Json.dll' is used from several locations:
 Packages/jillejr.newtonsoft.json-for-unity/Plugins/Newtonsoft.Json Standalone/Newtonsoft.Json.dll would be copied to <PluginPath>/Newtonsoft.Json.dll
 Packages/jillejr.newtonsoft.json-for-unity/Plugins/Newtonsoft.Json AOT/Newtonsoft.Json.dll would be copied to <PluginPath>/Newtonsoft.Json.dll
Please fix plugin settings and try again.

UnityEditor.Modules.DefaultPluginImporterExtension:CheckFileCollisions(String)
UnityEditorInternal.PluginsHelper:CheckFileCollisions(BuildTarget) (at C:/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.EditorApplication:Internal_CallGlobalEventHandler()

The define constraints seems to not work at all.

Steps to reproduce

  1. New Unity project (tested with 2018.3, 2018.4, 2019.1)
  2. Add Newtonsoft.Json-for-Unity package via Unity Package Manager
  3. In Unity, open Player settings and set Runtime to IL2CPP
  4. Build

Originally posted by @maskedmouse in JamesNK#2044 (comment)

@applejag applejag self-assigned this Jul 24, 2019
@applejag applejag added the bug Something isn't working label Jul 24, 2019
@applejag applejag changed the title Building causes plugin collision Building on standalone causes plugin collision Jul 24, 2019
@applejag
Copy link
Owner Author

This is known issue at Unity. Found in 2018.3.0a5, 2018.3.6f1, 2019.1.0a1, 2019.2.0a1

https://issuetracker.unity3d.com/product/unity/issues/guid/1143118

@MichalPetryka
Copy link

MichalPetryka commented Jul 30, 2019

Would it be possible to have source instead of the dlls in the package and use the defines inside of the code instead?

@applejag
Copy link
Owner Author

It is fully possible, and I've been using this method during dev of this fork, but there are some annoying problems in that implementation when it comes to publishing.

First minor thing is it would require using assembly definitions, which does not support non-asmdef code (as you must explicitly reference them), but secondly it requires you to either add all the following defines as well to your project settings...

NET462;UNITY_LTS;HAVE_ADO_NET;HAVE_APP_DOMAIN;HAVE_ASYNC;HAVE_BIG_INTEGER;HAVE_BINARY_EXCEPTION_SERIALIZATION;HAVE_BINARY_FORMATTER;HAVE_BINARY_SERIALIZATION;HAVE_CHAR_TO_LOWER_WITH_CULTURE;HAVE_CHAR_TO_STRING_WITH_CULTURE;HAVE_COM_ATTRIBUTES;HAVE_COMPONENT_MODEL;HAVE_CONCURRENT_COLLECTIONS;HAVE_CONCURRENT_DICTIONARY;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DB_NULL_TYPE_CODE;HAVE_DYNAMIC;HAVE_EMPTY_TYPES;HAVE_ENTITY_FRAMEWORK;HAVE_EXPRESSIONS;HAVE_FAST_REVERSE;HAVE_FSHARP_TYPES;HAVE_FULL_REFLECTION;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_ICLONEABLE;HAVE_ICONVERTIBLE;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_MEMORY_BARRIER;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_SECURITY_SAFE_CRITICAL_ATTRIBUTE;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STREAM_READER_WRITER_CLOSE;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_TRACE_WRITER;HAVE_TYPE_DESCRIPTOR;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT;HAVE_XML_DOCUMENT_TYPE

...or go through entire Newtonsoft.Json namespace and replace all above debug symbols with ENABLE_IL2CPP or something. That would be very labor intensive and would make merging from the source repo very tedious.


This is however fixed in the patch 12.0.1-patch-001. Requires manual update via the manifest.json:

@@ manifest.json @@
{
  "scopedRegistries": [
    {
      "name": "Packages from jillejr",
      "url": "https://registry.npmjs.org/",
      "scopes": [
        "jillejr"
      ]
    }
  ],
  "dependencies": {
    "com.unity.package-manager-ui": "2.1.2",
-    "jillejr.newtonsoft.json-for-unity": "12.0.1",
+    "jillejr.newtonsoft.json-for-unity": "12.0.1-patch-001",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",

applejag added a commit that referenced this issue Jul 30, 2019
* Fixed build
* Upped version to 12.0.1-patch-001
* Added changelog
* Updated README.md
@horeatrinca
Copy link

Hello! I still get this exact error with "12.0.1-patch-001". I was building for Windows, Linux, Mac then upgraded to Unity 2019.2.4f1 and after doing some more builds I got this error. Not sure what exactly triggered it.

@applejag
Copy link
Owner Author

Hello! I still get this exact error with "12.0.1-patch-001". I was building for Windows, Linux, Mac then upgraded to Unity 2019.2.4f1 and after doing some more builds I got this error. Not sure what exactly triggered it.

Interesting! What version were you on prior to 2019.2.4f1?

@applejag applejag reopened this Sep 11, 2019
@horeatrinca
Copy link

It was 2019.1.14f1. Maybe also worth noting that I was using our CI/CD pipeline and running Unity through the CLI - could be something wrong on my end!

@applejag
Copy link
Owner Author

@horeatrinca Say what container? Windows or Linux? What distro? What image? (gableroux perhaps?)

@horeatrinca
Copy link

Our build machine is on the latest Windows 10, not running in any VM. Just an honest install on a PC :)

@dFlynnSo
Copy link

We have the same Problem too, Unity3D Platform Windows (10) 64 Bit, Scripting Backend is IL2CPP
Version of Json is: 12.0.1-patch-001
Unity3D Version is: 2019.2.6f1

@applejag
Copy link
Owner Author

@dFlynnSo It's due odd. The 12.0.1-patch-001 should not contain files to even trigger a plugin collision, even caused by the define constraint conflicts as mentioned in the https://issuetracker.unity3d.com/product/unity/issues/guid/1143118 issue.

I'll give this a full shot this week.

@iiidefektiii
Copy link

I was having the same issues 2018.3.7 and 12.0.1
Switched to 12.0.1-patch-001 and it builds now if its any help on which versions work.

@applejag
Copy link
Owner Author

applejag commented Oct 6, 2019

Sorry @horeatrinca and @dFlynnSo but I am unable to reproduce this issue with 12.0.1-patch-001. Tried all my tricks on 2019.1.0f1, 2019.1.12f1, and 2019.2.8f1 but received no issues when building with IL2CPP.

Things you might try as sanity checks is closing Unity, deleting the /Library folder, and opening again (to force a refresh of DLL's).

Could any of you possibly produce a minimal reproduction project (sent via ex: email)?

@horeatrinca
Copy link

Thanks for looking into it @jilleJr. When I have more time I will try to reproduce it and give you more specific details!

@applejag applejag added the bug:builing Building in Unity fails due to bug label Oct 18, 2019
@callinutter
Copy link

Things you might try as sanity checks is closing Unity, deleting the /Library folder, and opening again (to force a refresh of DLL's).

That solved it for me. Highly appreciate your work and effort! I was devestaed when it didn't work after inserting your package in my project for my iOS build. But after deleting Library folder it finally build! :)

@applejag
Copy link
Owner Author

This seems to be fully resolved. Closing due to inactivity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:builing Building in Unity fails due to bug bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants