This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
"Filename longer than 260 characters" error on Windows
Edit page
Learn how to fix the "Filename longer than 260 characters" error when building an Android app on Windows.
When you build an Android app on Windows, the native (C++) build can fail with an error like this:
Execution failed for task ':app:buildCMakeDebug[arm64-v8a]'. C++ build system [build] failed while executing: ninja: error: Stat(safeareacontext_autolinked_build/CMakeFiles/react_codegen_safeareacontext.dir/D_/my-project/node_modules/react-native-safe-area-context/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp.o): Filename longer than 260 characters
Why this happens
The New Architecture compiles C++ code for each native library, and the generated object files are nested deeply under android/app/.cxx. With a project in a deep folder, or a package with a long name, their full paths exceed 260 characters, the default path limit on Windows.
The error comes from Ninja, the build tool that CMake uses. Ninja supports longer paths in version 1.12.0 and later. By default, Android builds use the Android SDK's CMake 3.22.1 package, which includes Ninja 1.10.2. Ninja 1.12 also needs long paths to be enabled in Windows.
Solution
Enable long paths in Windows
Set the LongPathsEnabled registry value. Run the following command in PowerShell as an administrator, then restart your computer:
For other ways to set it, such as Group Policy, see Maximum Path Length Limitation in the Windows documentation.
Use a newer CMake version
Enabling long paths isn't enough on its own, because Ninja 1.10.2 doesn't support them. Install a newer CMake package, which includes a newer Ninja. For example, the Android SDK's CMake 3.31.6 package includes Ninja 1.12.1.
- In Android Studio, open Settings > Languages & Frameworks > Android SDK > SDK Tools, select Show Package Details, and install CMake 3.31.6 under CMake.
- Set the
android.cmakeVersionGradle property in the gradle.properties file in your Gradle user home, %USERPROFILE%\.gradle\gradle.properties. Create the file if it doesn't exist:
- Delete android/app/.cxx and android/app/build so that CMake regenerates its build files, and then build again.
In SDK 57 and later, Expo reads the android.cmakeVersion property, both in projects that use prebuild and in projects that include an android directory. This file is on your computer and isn't part of your project. Builds on EAS Build and on other computers keep using the default CMake version.
Set the CMake version in your project
You can also set the CMake version in your project, with the android.cmakeVersion option of expo-build-properties in app.json, or with the android.cmakeVersion property in android/gradle.properties. The setting then applies to every build of the project, including builds on EAS Build. EAS Build runs Android builds on Linux, where the path limit doesn't apply. CMake 3.31.6 isn't installed there, so the build fails with CMake '3.31.6' was not found in SDK, PATH, or by cmake.dir property.
If your project uses prebuild, you can set the CMake version only when you build on Windows. Add the expo-build-properties entry in app.config.js instead of app.json:
EAS Build runs npx expo prebuild on its Linux build server, so cmakeVersion isn't set there. On your computer, run npx expo prebuild --clean after changing the config.
Move the project to a shorter path
To confirm that the path length is the cause, or as a workaround, move the project to a short folder such as C:\dev\my-app and build again.
The
git config core.longpaths truesetting doesn't affect the Android build. It only matters if Git fails to check out files with long paths.