Unity构建Android版本时出现cmd.exe未识别错误求助
Unity构建Android版本时
cmd.exe未识别错误排查 错误日志
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':unityLibrary:buildCMakeRelWithDebInfo[arm64-v8a]'. > com.android.ide.common.process.ProcessException: ninja: Entering directory `D:\Dunk\.utmp\RelWithDebInfo\2p271f5i\arm64-v8a' [0/1] Re-running CMake... -- Configuring done -- Generating done -- Build files have been written to: D:/Dunk/.utmp/RelWithDebInfo/2p271f5i/arm64-v8a [1/1] Linking CXX shared library D:\Dunk\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build\intermediates\cxx\RelWithDebInfo\2p271f5i\obj\arm64-v8a\libswappywrapper.so FAILED: D:/Dunk/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/build/intermediates/cxx/RelWithDebInfo/2p271f5i/obj/arm64-v8a/libswappywrapper.so cmd.exe /C "cd . && "D:\Unity Assets\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe" --target=aarch64-none-linux-android31 --sysroot="D:/Unity Assets/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/sysroot" -fPIC -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -Wall -Wextra -pedantic -Werror -O2 -g -DNDEBUG -Wl,--build-id=sha1 -Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined -Wl,--wrap=__android_log_print -shared -Wl,-soname,libswappywrapper.so -o D:\Dunk\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build\intermediates\cxx\RelWithDebInfo\2p271f5i\obj\arm64-v8a\libswappywrapper.so FramePacing/CMakeFiles/swappywrapper.dir/UnitySwappyWrapper.cpp.o -landroid C:/Users/muham/.gradle/caches/transforms-3/121b6b243cedf8bef90d462440e4bf24/transformed/jetified-games-frame-pacing-1.10.0/prefab/modules/swappy_static/libs/android.arm64-v8a_API31_NDK23_cpp_shared_Release/libswappy.a -llog -latomic -lm && cmd.exe /C "cd /D D:\Dunk\.utmp\RelWithDebInfo\2p271f5i\arm64-v8a\FramePacing && "D:\Unity Assets\Sdk\cmake\3.22.1\bin\cmake.exe" -E copy D:/Dunk/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/build/intermediates/cxx/RelWithDebInfo/2p271f5i/obj/arm64-v8a/libswappywrapper.so D:\Dunk\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary/symbols/arm64-v8a/libswappywrapper.so"" 'cmd.exe' is not recognized as an internal or external command, operable program or batch file. ninja: build stopped: subcommand failed. C++ build system [build] failed while executing: @echo off "D:\\Unity Assets\\Sdk\\cmake\\3.22.1\\bin\\ninja.exe" ^ -C ^ "D:\\Dunk\\.utmp\\RelWithDebInfo\\2p271f5i\\arm64-v8a" ^ swappywrapper from D:\Dunk\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 9s UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
已尝试无效方案
- 更换多个版本的Google Ad SDK
- 更换不同Unity版本
排查解决步骤
- 检查系统环境变量:确认系统
Path变量中包含C:\Windows\System32(cmd.exe所在目录),若缺失则添加,添加后重启电脑生效。 - 配置Unity终端路径:打开Unity编辑器,依次进入
Edit > Preferences > External Tools,将Terminal设置为系统默认cmd,或手动指定路径C:\Windows\System32\cmd.exe。 - 以管理员身份运行Unity:避免权限不足导致无法调用系统命令工具。
- 清理项目缓存:删除项目目录下的
Library、Temp、.utmp文件夹,重新构建项目。 - 修正NDK/SDK路径:将Unity使用的NDK/SDK移动到无空格、无特殊字符的路径下(例如原路径
D:\Unity Assets\Sdk可改为D:\UnitySDK),并在Unity的External Tools中更新对应路径。
内容的提问来源于stack exchange,提问作者Muhammad Ibrar
相关产品推荐
相关产品推荐

