无法在 HoloLens 2 上构建和 运行 Unity 应用程序
Unable to build and run Unity application on HoloLens 2
我正在尝试使用 Unity 构建我的第一个 HoloLens 应用程序。我导入了 MRTK 及其功能。我还通过 USB 连接了 HoloLens。只要我按下“Build and 运行”,它就会提供 3 个错误。我的通用 Windows 平台构建设置如下:
- 目标设备:HoloLens,
- 架构师:ARM(我也试过ARM64),
- 构建类型:D3D 项目,
- 目标 SDK 版本:最新安装,
- 最低平台版本:(所有版本都给出相同的错误),
- Visual Studio 版本:最新安装,
- 构建并 运行 于:USB 设备,
- 构建配置:发布。
无论构建设置如何,按下“Build and 运行”后立即出现以下错误:
BuildFailedException: Deployment failed.
Output:[22:13:39.766] Windows Phone Player Runner started.
[22:13:39.772] Connecting to device.
[22:13:39.788] An error occurred while running: Could not load file or assembly 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.SmartDevice.Connectivity.DatastoreManager..ctor(DatastoreConfiguration configuration)
at Microsoft.SmartDevice.Connectivity.DatastoreManager.Get(Int32 localeId)
at Microsoft.SmartDevice.Connectivity.Wrapper.ConnectivityWrapper12.GetCurrentPlatform(Int32 localeId)
at WindowsPhonePlayerRunner.Program.GetDevice()
at WindowsPhonePlayerRunner.Program.Run(String appxPath, RunnerFlags runnerFlags, IEnumerable`1 copyFilesTo)
at WindowsPhonePlayerRunner.Program.Main(String[] args)
[22:13:39.788] Exiting Windows Phone Player Runner.
ApplicationLauncherImpl.RunOnPhone (System.String commandLine)
ApplicationLauncherImpl.Run (Utility+VisualStudio vs)
ApplicationLauncher.BuildAndRunProject (UnityEditor.Modules.BuildLaunchPlayerArgs args, UnityEditor.WSABuildAndRunDeployTarget deployTarget, System.String platform, Utility+VisualStudio vs)
UnityEditor.PostprocessBuildPlayer.Launch (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, System.String path, System.String productName, UnityEditor.BuildOptions options, UnityEditor.Build.Reporting.BuildReport buildReport) (at <55729f52d042492e9efc384182ae2feb>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 177 seconds (176835 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <55729f52d042492e9efc384182ae2feb>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <55729f52d042492e9efc384182ae2feb>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
从构建日志来看,“Windows Phone Player 运行ner”相关的输出应该是由两个可能的原因引起的:
- Unity 版本不正确。
- 构建并运行:USB 设备 设置
对于Unity版本,我们建议使用Unity 2020 LTS版本进行HoloLens 2开发:https://unity3d.com/unity/qa/lts-releases?version=2020.3
对于 Build 和 运行 on 设置,问题是由 Build 和 运行 on: USB Device 设置引起的,这是一个已知的 issue 并且不会被 Unity 修复。最佳做法是,请切换到 Local Machine 并生成 Visual Studio 项目。在 Visual Studio 的帮助下,您可以通过无线网络或 USB 数据线部署到 HoloLens 2。参见:
- 在此 tutorial
中构建和部署应用程序 部分
- Using Visual Studio to deploy and debug
我正在尝试使用 Unity 构建我的第一个 HoloLens 应用程序。我导入了 MRTK 及其功能。我还通过 USB 连接了 HoloLens。只要我按下“Build and 运行”,它就会提供 3 个错误。我的通用 Windows 平台构建设置如下:
- 目标设备:HoloLens,
- 架构师:ARM(我也试过ARM64),
- 构建类型:D3D 项目,
- 目标 SDK 版本:最新安装,
- 最低平台版本:(所有版本都给出相同的错误),
- Visual Studio 版本:最新安装,
- 构建并 运行 于:USB 设备,
- 构建配置:发布。
无论构建设置如何,按下“Build and 运行”后立即出现以下错误:
BuildFailedException: Deployment failed.
Output:[22:13:39.766] Windows Phone Player Runner started.
[22:13:39.772] Connecting to device.
[22:13:39.788] An error occurred while running: Could not load file or assembly 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.SmartDevice.Connectivity.DatastoreManager..ctor(DatastoreConfiguration configuration)
at Microsoft.SmartDevice.Connectivity.DatastoreManager.Get(Int32 localeId)
at Microsoft.SmartDevice.Connectivity.Wrapper.ConnectivityWrapper12.GetCurrentPlatform(Int32 localeId)
at WindowsPhonePlayerRunner.Program.GetDevice()
at WindowsPhonePlayerRunner.Program.Run(String appxPath, RunnerFlags runnerFlags, IEnumerable`1 copyFilesTo)
at WindowsPhonePlayerRunner.Program.Main(String[] args)
[22:13:39.788] Exiting Windows Phone Player Runner.
ApplicationLauncherImpl.RunOnPhone (System.String commandLine)
ApplicationLauncherImpl.Run (Utility+VisualStudio vs)
ApplicationLauncher.BuildAndRunProject (UnityEditor.Modules.BuildLaunchPlayerArgs args, UnityEditor.WSABuildAndRunDeployTarget deployTarget, System.String platform, Utility+VisualStudio vs)
UnityEditor.PostprocessBuildPlayer.Launch (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget buildTarget, System.String path, System.String productName, UnityEditor.BuildOptions options, UnityEditor.Build.Reporting.BuildReport buildReport) (at <55729f52d042492e9efc384182ae2feb>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Build completed with a result of 'Failed' in 177 seconds (176835 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in <55729f52d042492e9efc384182ae2feb>:0
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <55729f52d042492e9efc384182ae2feb>:0
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
从构建日志来看,“Windows Phone Player 运行ner”相关的输出应该是由两个可能的原因引起的:
- Unity 版本不正确。
- 构建并运行:USB 设备 设置
对于Unity版本,我们建议使用Unity 2020 LTS版本进行HoloLens 2开发:https://unity3d.com/unity/qa/lts-releases?version=2020.3
对于 Build 和 运行 on 设置,问题是由 Build 和 运行 on: USB Device 设置引起的,这是一个已知的 issue 并且不会被 Unity 修复。最佳做法是,请切换到 Local Machine 并生成 Visual Studio 项目。在 Visual Studio 的帮助下,您可以通过无线网络或 USB 数据线部署到 HoloLens 2。参见:
- 在此 tutorial 中构建和部署应用程序 部分
- Using Visual Studio to deploy and debug