助力快速解决 Unity IL2CPP 打包异常 为初学者节省宝贵的时间,避免采坑! |
我们的初衷是将一种简单的生活方式带给世人 使有限时间 具备无限可能 |
Chinar 教程效果:
Intro —— 简介
IL2CPP 打包方式的优点不用我说,网上能搜到一堆讲的很官方的教程
总之成品项目发布版本时,用它就对了
但这种打包方式,各种的花式报错。而且Baidu 搜索不到与之对应的解决方案,对初学者来讲这点尤为头疼!
4
Quote UnityEditor —— 脚本引用 UnityEditor,导致无法打包
错误发生场景
打包项目/工程时报错
Unity IL2CPP 无论怎样都报错,甚至新建空项目打包也报错!
具体报错信息: |
---|
Failed running D:\WorkWare\UnityHub\Unity\2018.4.13c1\Editor\Data\il2cpp/build/il2cpp.exe --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Release" --outputpath="D:\WorkWare\WorkProject\TEST\Chinar String Edge\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="D:\WorkWare\WorkProject\TEST\Chinar String Edge\Assets\..\Library/il2cpp_cache" --map-file-parser="D:\WorkWare\UnityHub\Unity\2018.4.13c1\Editor\Data\Tools\MapFileParser\MapFileParser.exe" --directory="D:\WorkWare\WorkProject\TEST\Chinar String Edge\Temp\StagingArea\Data\Managed" --generatedcppdir="D:\WorkWare\WorkProject\TEST\Chinar String Edge\Temp\StagingArea\Data\il2cppOutput"
stdout:
il2cpp.exe didn't catch exception: System.InvalidOperationException: C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
Visual Studio 2010 with C++ compilers and Windows 7 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2010 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\10.0_Config\InstallDir" in the registry
Windows 7 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder" in the registry
Visual Studio 2013 with C++ compilers and Windows 8.1 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2013 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\12.0_Config\InstallDir" in the registry
Windows 8.1 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1\InstallationFolder" in the registry
Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
Visual Studio 2017 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2017 installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
�� Unity.IL2CPP.Building.CppProgramBuilder.ThrowIfCannotBuildInCurrentEnvironment()
�� Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
�� il2cpp.Program.DoRun(String[] args)
�� il2cpp.Program.Run(String[] args)
�� il2cpp.Program.Main(String[] args)
stderr:
δ��������쳣: System.InvalidOperationException: C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
Visual Studio 2010 with C++ compilers and Windows 7 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2010 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\10.0_Config\InstallDir" in the registry
Windows 7 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder" in the registry
Visual Studio 2013 with C++ compilers and Windows 8.1 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2013 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\12.0_Config\InstallDir" in the registry
Windows 8.1 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1\InstallationFolder" in the registry
Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
Visual Studio 2017 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
Visual Studio 2017 installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
�� Unity.IL2CPP.Building.CppProgramBuilder.ThrowIfCannotBuildInCurrentEnvironment()
�� Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
�� il2cpp.Program.DoRun(String[] args)
�� il2cpp.Program.Run(String[] args)
�� il2cpp.Program.Main(String[] args)
Exception: D:\WorkWare\UnityHub\Unity\2018.4.13c1\Editor\Data\il2cpp/build/il2cpp.exe did not run properly!
UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] in D:\unity\Editor\Mono\BuildPlayerWindowBuildMethods.cs:194
at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in D:\unity\Editor\Mono\BuildPlayerWindowBuildMethods.cs:97
解决方案: |
---|
- 根据控制台输出内容,我们可以得知是电脑没安装相应 WindowsSDK 造成的
- 打开 VS 选项中找到获取新功能,安装 window10 /对应 系统SDK)
- 即可成功打包工程
支持
May Be —— 开发者,总有一天要做的事!
Chinar 提供一站式《零》基础教程 使有限时间 具备无限可能! |
Chinar 免费服务器、建站教程全攻略!( Chinar Blog )
本博客为非营利性个人原创,除部分有明确署名的作品外,所刊登的所有作品的著作权均为本人所拥有,本人保留所有法定权利。违者必究
对于需要复制、转载、链接和传播博客文章或内容的,请及时和本博主进行联系,留言,Email: ichinar@icloud.com
对于经本博主明确授权和许可使用文章及内容的,使用时请注明文章或内容出处并注明网址