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

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:

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?)

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?)
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:

Instance of UnityEditor.XR.OpenXR.OpenXRPackageSettings couldn't be created because there is no script with that name.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
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.
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.

1 Like

At some point in Unity’s recent release cycles you need to add this line to your Packages/manifest.json file:

"com.unity.nuget.newtonsoft-json": "3.0.2",

Or you can add it the painful way with the package mangler. :slight_smile:

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.

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

Android Gradle errors and other related stuff:

8 Likes

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.

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

I’m using macOS Ventura.

Thanks again or the help.

Okay, important clarification: there is no OpenXR 1.6.0—what I meant was the OpenXR Unity plugin (com.unity.xr.openxr)

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.

here’s the test project where I was able to reproduce it. thanks!

8748285–1185063–My project (1) 2.zip (132 KB)

any updates on this?

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.

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?

@lianne13 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.

1 Like

@lianne13 The OpenXRPackageSettings occur regardless of the platform selected.

1 Like

@lianne13 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.

1 Like

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!

1 Like

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.

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.

Solution wokred thank you!

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.

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.

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

Thanks This works!! :slight_smile: