Search Unity

Bug The type or namespace name 'Newtonsoft' could not be found, and more in 2022.2.2f1 update.

Discussion in 'Editor & General Support' started by jonkelling, Jan 15, 2023.

  1. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    I was building and running to PC and Quest 2 on version 2022.2.1f1. After updating to 2022.2.2f1, I'm now getting the following errors only when building for Android:

    Code (CSharp):
    1. Library/PackageCache/com.unity.services.core@1.7.0/Runtime/Core.Internal/Registry/DependencyTreeExtensions.cs(4,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
    Library/PackageCache/com.unity.services.core@1.7.0/Runtime/Core.Internal/Registry/DependencyTreeExtensions.cs(4,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)

    Code (CSharp):
    1. Library/PackageCache/com.unity.services.core@1.7.0/Runtime/Core.Internal/Registry/DependencyTreeExtensions.cs(51,24): error CS0246: The type or namespace name 'JObject' could not be found (are you missing a using directive or an assembly reference?)
    Code (CSharp):
    1. Library/PackageCache/com.unity.services.core@1.7.0/Runtime/Core.Internal/Registry/DependencyTreeExtensions.cs(74,24): error CS0246: The type or namespace name 'JObject' could not be found (are you missing a using directive or an assembly reference?)
    Separately, I'm also getting errors about not being able to find a class in a DLL, which is being referenced by a small bit of code in its own isolated assembly definition.

    Lastly, after a domain reload, or just opening Unity, I get the following two errors:

    Code (CSharp):
    1. Instance of UnityEditor.XR.OpenXR.OpenXRPackageSettings couldn't be created because there is no script with that name.
    2. UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
    Code (CSharp):
    1. We were unable to create an instance of the requested type UnityEditor.XR.OpenXR.OpenXRPackageSettings. Please make sure that all packages are updated to support this version of XR Plug-In Management. See the Unity documentation for XR Plug-In Management for information on resolving this issue.
    2. UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:361)
    ^ Related to the OpenXR issues, going to 2022.2.2f1 updated OpenXR from 1.5.3 to 1.6.0. I posted this in the OpenXR issue tracker, and they said it was a Unity problem.
     
    kin97 likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,734
    At some point in Unity's recent release cycles you need to add this line to your Packages/manifest.json file:

    Code (csharp):
    1. "com.unity.nuget.newtonsoft-json": "3.0.2",
    Or you can add it the painful way with the package mangler. :)

    The other stuff looks similarly like an out-of date package but I don't use the XR stuff.

    In general:

    How to troubleshoot build failures:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Android Gradle errors and other related stuff:

    https://forum.unity.com/threads/unity-gradle-bug-please-help.1368018/#post-8625789
     
  3. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    Hello, thanks for your reply!

    I have this already. The error is not a general compilation error. It only shows up while trying to build.

    The OpenXR (unity plugin) error, while saying it cannot find the class, definitely can in all the places I'm aware of—i.e. I can edit the scriptable object in the Unity Editor as well as access the class via code.

    Okay, this didn't take long at all to my surprise.

    1. New URP Project
    2. Added top-level assembly def with android, windows, editor, and reference to #3
    3. Added that isolated assembly def with DLL I mentioned, including test code referencing the class it couldn't find
    4. Built fine
    5. Added com.unity.xr.openxr 1.5.3—figured I'd try the older version first—worked.
    6. Changed to com.unity.xr.openxr 1.6.0—all errors I mentioned came up immediately while building
    7. Removed top-level assembly definition—no change
    8. Removed isolated assdef/DLL/related code—no change (except those particle errors went away)

    I'm using macOS Ventura.

    Thanks again or the help.
     
    Last edited: Jan 16, 2023
  4. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    Okay, important clarification: there is no OpenXR 1.6.0—what I meant was the OpenXR Unity plugin (com.unity.xr.openxr)
     
  5. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    105
    Hey, I didn't see the error you described above. Could you please zip up your project and sent it to me? We could take a quick look to see if anything is wrong.
    Thanks.
     
  6. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    here's the test project where I was able to reproduce it. thanks!
     

    Attached Files:

  7. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    any updates on this?
     
  8. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    Same thing on Windows 10, by the way. I'd upgrade to Windows 11, but one of my team members has Windows 11 and is getting other issues from an OpenXR plugin (not sure which one), and the only difference I'm aware of is the OS we're using.
     
  9. lianne13

    lianne13

    Unity Technologies

    Joined:
    Jan 31, 2023
    Posts:
    21
    Hey @jonkelling,

    I tried to recreate the bug you mentioned through the test project you provided, and by following the step you mentioned above with creating a new project. However, I was unable to recreate the error you mentioned.

    Is there any other information you could provide that may possible help me reproduce this bug?
     
    Last edited: Feb 16, 2023
  10. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    @LianneUnityXR I wish I could. This occurs for me on Mac OS X and Windows 10 as well as for other members of my team. We are using VS Code as the code editor. Visual Studio 2022 with C++ and Win 10 SK are installed. I can't think of anything else out of the ordinary that's going on.
     
    lianne13 likes this.
  11. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    @LianneUnityXR The OpenXRPackageSettings occur regardless of the platform selected.
     
    lianne13 likes this.
  12. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    @LianneUnityXR I'm developing for Oculus. Oculus and Steam are both installed. I know that alters the feature groups available in the OpenXR Package settings. Sorry for the ping again, but that just popped in my head.
     
    lianne13 likes this.
  13. lianne13

    lianne13

    Unity Technologies

    Joined:
    Jan 31, 2023
    Posts:
    21
    No worries appreciate all and any info you can provide!

    Ok I will ask around my team and see if someone has an ideal on how to reproduce this issue.

    I'll be sure to update you once I know something!
     
    jonkelling likes this.
  14. lianne13

    lianne13

    Unity Technologies

    Joined:
    Jan 31, 2023
    Posts:
    21
    Hey @jonkelling,

    So, unfortunately neither I nor my teammates were able to reproduce the issue you've been having. I could potentially be something local/project specific that is causing this or something entirely different. However, I do not have any solution for you at this time as we cannot recreate the issue.

    If you are able to provide a more specific sample project or reproduction steps for recreating this issues we can attempt to resolve this again. Otherwise, in the meantime we will be sure to keep an eye out for if any other users come across this issue and circle back to try to address it.

    I wish I had better news for you, and hope you are able to find a solution that will allow you to continue with your work.
     
    Last edited: Mar 6, 2023
  15. jonkelling

    jonkelling

    Joined:
    Dec 18, 2019
    Posts:
    21
    As of now it's happened on several entirely different computers, on brand new projects using the steps I listed. It would seem that there's nothing specific about any of the setups that would cause it, and the result is always the same. I'll try again in the future with different versions, or perhaps provide a VM for you that has the issue on it. Thank you for looking into it, though.
     
  16. kin97

    kin97

    Joined:
    May 18, 2023
    Posts:
    1
    Solution wokred thank you!
     
  17. RiverExplorer

    RiverExplorer

    Joined:
    Jul 28, 2021
    Posts:
    21
    I had the same problem on one copy of my project. I suspect it is a corrupt object of some kind. It is literally a copy of the original project, with some totally unrelated things being debugged. I never did figure it out. Is all I had to do to recreate it, was copy the project to reproduce the bug. I used Windows copy/pase, xcopy, it did not seem to matter how I copied it. Then I noticed I was copying it to another disk drive. When I copied to the same disk drive, all worked. It might be some microsoft permissions bug when copying a file. Then one day, the problem went away.
     
  18. RiverExplorer

    RiverExplorer

    Joined:
    Jul 28, 2021
    Posts:
    21
    I am getting similar problem today. Oculus.Platform seems to no longer be defined on some lines, and is allowed and known on other lines in the same file. I suspect some kind of namespace collision problem.
     
  19. Yazan-3Lines

    Yazan-3Lines

    Joined:
    Nov 15, 2023
    Posts:
    2
    I had the same problem, the fix was to delete the all the files and regenerate them, just make sure to not delete these folders (Assets,Packages,ProjectSettings) and delete anything else
     
  20. astechnolabs

    astechnolabs

    Joined:
    Jul 11, 2021
    Posts:
    24

    Thanks This works!! :)