Cannot build android platform with VisionOS installed

I have a project where I have both VisionOS and Android build targets, but when I build for Android I get this error:

Fatal error in Unity CIL Linker
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Unity.PolySpatial, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
   at Unity.IL2CPP.Common.MissingMethodStubber.GetTypeModule(TypeReference type, IEnumerable`1 assemblies)
   at Unity.Linker.Steps.AddUnresolvedStubsStep.MarkAssemblyOfType(UnityLinkContext context, TypeReference type)
   at Unity.Linker.Steps.Marking.UnresolvedStubMarking.HandleUnresolvedType(TypeReference reference)
   at Unity.Linker.Steps.UnityMarkStep.HandleUnresolvedType(TypeReference reference)
   at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
   at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca, IMemberDefinition sourceLocationMember)
   at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(IMemberDefinition source, CustomAttribute ca)
   at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason, IMemberDefinition source)
   at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason, IMemberDefinition sourceLocationMember)
   at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet`1 typesAlreadyVisited)
   at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
   at Unity.Linker.Steps.UnityMarkStep.InitializeAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.MarkStep.Initialize()
   at Unity.Linker.Steps.UnityMarkStep.Process(LinkContext context)
   at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at Unity.Linker.UnityDriver.UnityRun(UnityLinkContext context, UnityPipeline p, LinkRequest linkerOptions, TinyProfiler2 tinyProfiler, ILogger customLogger)
   at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(TinyProfiler2 tinyProfiler, ILogger customLogger)
   at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
   at Unity.Linker.UnityDriver.RunDriver()

Packages:

"com.unity.collab-proxy": "2.5.2",
"com.unity.feature.development": "1.0.2",
"com.unity.learn.iet-framework": "4.0.2",
"com.unity.learn.iet-framework.authoring": "1.2.2",
"com.unity.multiplayer.center": "1.0.0",
"com.unity.polyspatial.visionos": "2.0.4",
"com.unity.polyspatial.xr": "2.0.4",
"com.unity.render-pipelines.universal": "17.0.3",
"com.unity.test-framework": "1.4.5",
"com.unity.xr.hands": "1.4.3",
"com.unity.xr.interaction.toolkit": "3.0.5",
"com.unity.xr.meta-openxr": "2.0.1",
"com.unity.modules.accessibility": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "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",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"

One issue that stands out is you have “com.unity.polyspatial.visionos” at “2.0.4”, but you have
“com.unity.polyspatial.xr” at “1.3.1”. These should be the same version number as we release them together. Try upgrading com.unity.polyspatial.xr to 2.0.4 as well.
The asmdef file for Unity.PolySpatial should be set to exclude Android in 2.0.4.

good catch. I didn’t notice the “com.unity.polyspatial.xr” version. I had to switch to the latest 6000.0.23f1 version today to finally see the update in the package manager.

I updated it, but still getting this error:

Fatal error in Unity CIL Linker
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Unity.PolySpatial, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
at Unity.IL2CPP.Common.MissingMethodStubber.GetTypeModule(TypeReference type, IEnumerable`1 assemblies)
at Unity.Linker.Steps.AddUnresolvedStubsStep.MarkAssemblyOfType(UnityLinkContext context, TypeReference type)
at Unity.Linker.Steps.Marking.UnresolvedStubMarking.HandleUnresolvedType(TypeReference reference)
at Unity.Linker.Steps.UnityMarkStep.HandleUnresolvedType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(IMemberDefinition source, CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason, IMemberDefinition source)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkEntireTypeInternal(TypeDefinition type, Boolean includeBaseTypes, DependencyInfo& reason, IMemberDefinition sourceLocationMember, HashSet`1 typesAlreadyVisited)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Unity.Linker.Steps.UnityMarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Unity.Linker.Steps.UnityMarkStep.Process(LinkContext context)
at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Unity.Linker.UnityDriver.UnityRun(UnityLinkContext context, UnityPipeline p, LinkRequest linkerOptions, TinyProfiler2 tinyProfiler, ILogger customLogger)
at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(TinyProfiler2 tinyProfiler, ILogger customLogger)
at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
at Unity.Linker.UnityDriver.RunDriver()

I have the same problem here with 6000.0.22f1.

Here is my test project. Check out the Actions tab for full logs

Thanks for reporting this, and the repro project, definitely helps speed things along.

I was able to repro, and I have a work around for you to unblock you:
You are going to need to find where the com.unity.polyspatial package is installed on your system and copy it somewhere local so you can modify it.
edit your Packages/manifest.json file.
If you don’t have an entry for “com.unity.polyspatial”, you will need to add one. (For your project its just not listed because its a dependency for com.unity.polyspatial.visionos.)
For the value for its entry you will want to point it to where you copied the package to. For example:
“com.unity.polyspatial”: “file:/whereever_you_copied_it_to/Packages/com.unity.polyspatial/”,
Then within the package locate:
com.unity.polyspatial/Runtime/Public/Unity.PolySpatial.asmdef
find:
“excludePlatforms”: [
“Android”
],
and remove “Android”.
I tested this with your sample project and confirm I was able to generate an apk after doing this.
I’m going to file a bug about this internally and work to get a patch release out so you guys wont have to do this going forward. Sorry for the trouble.

Awesome, thanks Peter.

Cannot do that in the build CI but I’ll patiently wait for patch.

Any news regarding the patch?

Has this been fixed?