Unity 在为 Android 构建时在运行时抛出 IL2CPP 构建错误? 2018.4.5f1
Posted
技术标签:
【中文标题】Unity 在为 Android 构建时在运行时抛出 IL2CPP 构建错误? 2018.4.5f1【英文标题】:Unity throwing IL2CPP build error at run time when building for Android? 2018.4.5f1 【发布时间】:2021-03-01 05:42:17 【问题描述】:我正在尝试构建一个项目以部署到 Play 商店,但在构建时遇到了可怕的 IL2CPP 错误。以下是错误,都与同一个文件 il2cppcore.dll 相关。任何帮助表示赞赏。
Unity 版本 2018.4.5f1
我有……
选中 Build App Bundle (Play Store) 框
添加了 NDK r16b 64 位路径。
安装了 android Studio 和 sdk 工具,Unity 可以识别它们并成功使用 mono for x32 构建
通过 Android Studio 安装目标平台 API 22 并在播放器设置中进行设置。
在播放器设置中选中 ARMv7 和 ARMv64,并取消选中 x86
在设置中取消选中“Strip Engine Code”
当我第一次下载它并将 Unity 指向它的位置时,我不得不选择允许 clang++ 和 NDK 中的其他几个程序通过 Mac > System Prefs > Privacy & Security 运行。
Failed running /Applications/Unity/Unity.app/Contents/il2cpp/build/il2cppcore/il2cppcore.dll --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="Android" --architecture="ARMv7" --configuration="Release" --outputpath="/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a/libil2cpp.so" --cachedirectory="/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Assets/../Library/il2cpp_android_armeabi-v7a/il2cpp_cache" --additional-include-directories="/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" --additional-include-directories="/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" --tool-chain-path="/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b" --map-file-parser="/Applications/Unity/Unity.app/Contents/Tools/MapFileParser/MapFileParser" --directory="/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/assets/bin/Data/Managed" --generatedcppdir="/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/Il2Cpp/il2cppOutput"
stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: /Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/assets/bin/Data/Native/armeabi-v7a
Cache directory: /Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Library/il2cpp_android_armeabi-v7a/il2cpp_cache
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException:
Invocation was: Executable: /Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
Arguments: -DNET_4_0 -DUNITY_AOT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -D__linux__ -D__STDC_FORMAT_MACROS -I"/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" -I"/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" -I"/Applications/Unity/Unity.app/Contents/il2cpp/libil2cpp" -I"/Applications/Unity/Unity.app/Contents/il2cpp/external/boehmgc/include" -I"/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/Il2Cpp/il2cppOutput" -I"." -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include" -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward" -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -fPIC -Os --sysroot "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sysroot" -gcc-toolchain "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -isystem "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi" -D__ANDROID_API__=16 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-fp16 -Wno-unused-value "/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/Il2Cpp/il2cppOutput/Il2CppAttributes.cpp" -o "/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/F803C2153AA5C985B8E844104B91FF45.o"
at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
at il2cpp.Program.DoRun(String[] args)
at il2cpp.Program.Run(String[] args)
at il2cpp.Program.Main(String[] args)
stderr:
Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException:
Invocation was: Executable: /Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
Arguments: -DNET_4_0 -DUNITY_AOT -DGC_NOT_DLL -DRUNTIME_IL2CPP -DLINUX -DANDROID -DPLATFORM_ANDROID -D__linux__ -D__STDC_FORMAT_MACROS -I"/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/bdwgc/include" -I"/Applications/Unity/PlaybackEngines/AndroidPlayer/Tools/libil2cpp/include" -I"/Applications/Unity/Unity.app/Contents/il2cpp/libil2cpp" -I"/Applications/Unity/Unity.app/Contents/il2cpp/external/boehmgc/include" -I"/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/Il2Cpp/il2cppOutput" -I"." -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include" -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/backward" -I"/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include" -c -g -DNDEBUG -funwind-tables -fno-limit-debug-info -fdata-sections -ffunction-sections -Wa,--noexecstack -fno-rtti -std=c++98 -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -fno-strict-overflow -fPIC -Os --sysroot "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sysroot" -gcc-toolchain "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64" -target armv7-none-linux-androideabi -isystem "/Users/db639c/Library/Android/sdk/ndk/android-ndk-r16b/sysroot/usr/include/arm-linux-androideabi" -D__ANDROID_API__=16 -march=armv7-a -mfloat-abi=softfp -mfpu=neon-fp16 -Wno-unused-value "/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Temp/StagingArea/Il2Cpp/il2cppOutput/Il2CppAttributes.cpp" -o "/Users/db639c/Desktop/Projects/Unity 10ft/Data Testing v2/Library/il2cpp_android_armeabi-v7a/il2cpp_cache/F803C2153AA5C985B8E844104B91FF45.o"
at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
at il2cpp.Program.DoRun(String[] args)
at il2cpp.Program.Run(String[] args)
at il2cpp.Program.Main(String[] args)
at Program.Main(String[] args)
UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunNetCoreProgram(String, String, String, CompilerOutputParserBase, Action`1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:366)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
错误 2:
Exception: /Applications/Unity/Unity.app/Contents/il2cpp/build/il2cppcore/il2cppcore.dll did not run properly!
UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:130)
UnityEditorInternal.Runner.RunNetCoreProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79)
UnityEditorInternal.IL2CPPBuilder.RunIl2CppWithArguments (System.Collections.Generic.List`1[T] arguments, System.Action`1[T] setupStartInfo, System.String workingDirectory) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:366)
UnityEditorInternal.IL2CPPBuilder.ConvertPlayerDlltoCpp (System.String inputDirectory, System.String outputDirectory, System.String workingDirectory, System.Boolean platformSupportsManagedDebugging) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder.Run () (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:211)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:35)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <62f761e6ab1445a38cdcb4ac36512695>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <62f761e6ab1445a38cdcb4ac36512695>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <62f761e6ab1445a38cdcb4ac36512695>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <62f761e6ab1445a38cdcb4ac36512695>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:286)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
【问题讨论】:
【参考方案1】:对于那些面临这个问题的人来说,这是由于 Catalina 由于新的安全功能而不允许某些脚本运行造成的。我通过重新安装 r16 NDK 来修复它,转到安全和隐私,并确保每次在统一按下 BUILD 后遇到“[脚本名称] 被阻止运行”错误时,我都会单击“仍然允许”。 ..” 安全和隐私中的按钮,然后单击错误模式上的“取消”或“打开”。
构建会失败几次,但每次新脚本都会请求新的权限,最终它会通过所有需要的脚本并且构建会成功。
【讨论】:
尝试修复它几个月,这确实有帮助!谢谢以上是关于Unity 在为 Android 构建时在运行时抛出 IL2CPP 构建错误? 2018.4.5f1的主要内容,如果未能解决你的问题,请参考以下文章
Unity System 和 Newtonsoft 库在为 android 构建时不起作用
来自 Oculus 集成包的 Unity Spatializer,用于在未触及 Unity 时抛出错误
构建失败:无法在 Unity 上构建 Android .apk