Android Gradle release build fails with "path exceeds 260 characters" on Windows


I am building a React Native/Expo Android app on Windows and the debug build works, but when I try to build the release variant, Gradle fails with an error indicating that the file/path exceeds the 260-character Windows path limit.

The project is located in a relatively long directory path, and the error occurs during the Gradle release build.

Environment:

  • Windows 11

  • React Native / Expo

  • Android Studio

  • Gradle

  • Building release variant

Problem:
The release build fails because one or more generated Gradle paths exceed Windows' maximum path length.

I have tried cleaning the project and rebuilding, but the problem persists.

Question:
What is the recommended way to fix this issue? Should I move the project to a shorter directory, enable Windows long-path support, or configure Gradle/Android differently to avoid generating paths longer than 260 characters?

Any guidance on the proper solution would be appreciated.

2
Aug 27 at 12:31 PM
User AvatarAbhay
#android#windows#react-native

Accepted Answer

It is a Windows limitation on working directory path length.

You can enable long path support on Windows via Powershell :

Set-ItemProperty ` -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" ` -Name "LongPathsEnabled" ` -Type DWord ` -Value 1
User Avataroxccc
Aug 27 at 12:41 PM
3