🐛 Bug Report: Windows Build Fails - Path Exceeds 260 Character Limit
Summary
Android builds fail on Windows with New Architecture (Fabric) enabled due to generated file paths exceeding Windows' 260 character MAX_PATH limit.
🔴 Error
> Task :app:buildCMakeDebug[arm64-v8a] FAILED
ninja: error: Stat(reactnativekeyboardcontroller_autolinked_build/CMakeFiles/react_codegen_reactnativekeyboardcontroller.dir/C_/Users/Admin/Projects/BeingnexusNative/node_modules/react-native-keyboard-controller/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.cpp.o): Filename longer than 260 characters
📊 Path Analysis
| Component |
Length |
reactnativekeyboardcontroller_autolinked_build/ |
48 chars |
CMakeFiles/react_codegen_reactnativekeyboardcontroller.dir/ |
59 chars |
C_/Users/Admin/Projects/BeingnexusNative/ |
42 chars |
node_modules/react-native-keyboard-controller/ |
47 chars |
common/cpp/react/renderer/components/reactnativekeyboardcontroller/ |
68 chars |
RNKCKeyboardBackgroundViewShadowNode.cpp.o |
43 chars |
| Total |
~307 chars (exceeds 260 limit) |
Root Cause
The namespace reactnativekeyboardcontroller (32 chars) appears 4 times in the path, contributing ~128 characters.
🖥️ Environment
| Item |
Version |
| OS |
Windows 11 |
| React Native |
0.77.x (New Architecture) |
| react-native-keyboard-controller |
latest |
| Gradle |
9.0.0 |
| CMake |
3.22.1 |
| Architecture |
arm64-v8a |
📝 Reproduction Steps
- Create a new React Native project on Windows
- Enable New Architecture in
gradle.properties:
- Install the package:
npm install react-native-keyboard-controller
- Add
KeyboardProvider to App.tsx:
import { KeyboardProvider } from 'react-native-keyboard-controller';
export default function App() {
return (
<KeyboardProvider>
{/* ... */}
</KeyboardProvider>
);
}
- Build for Android:
npx react-native run-android
✅ Expected Behavior
Build should complete successfully on Windows.
❌ Actual Behavior
Build fails with Filename longer than 260 characters error.
💡 Suggested Fix
Option 1: Shorten Codegen Name (Recommended)
In package.json, use a shorter name for codegen:
{
"codegenConfig": {
"name": "rnkc", // Instead of "reactnativekeyboardcontroller"
...
}
}
Option 2: Shorten Internal Paths
Restructure cpp files:
Before: common/cpp/react/renderer/components/reactnativekeyboardcontroller/
After: cpp/rnkc/
Option 3: Shorten File Names
Before: RNKCKeyboardBackgroundViewShadowNode.cpp
After: KBBackgroundShadow.cpp
⚠️ Additional Warnings
The build also shows these deprecation warnings:
1. AndroidManifest package Attribute (Deprecated)
package="com.reactnativekeyboardcontroller" found in source AndroidManifest.xml.
Setting the namespace via the package attribute is no longer supported.
Recommendation: remove package attribute and use namespace in build.gradle.kts
2. Deprecated React Native APIs
LayoutShadowNode → deprecated
ReactShadowNodeImpl → deprecated
MapBuilder → Use Kotlin's built-in collections
UIManagerType.DEFAULT → Use LEGACY
statusBarColor → deprecated in Android API
FLAG_FULLSCREEN → deprecated
ReactFeatureFlags → Use ReactNativeFeatureFlags
🔧 Temporary Workarounds (For Users)
-
Enable Long Paths in Windows (requires admin + reboot):
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
-
Move project to shorter path:
C:\app\ # Instead of C:\Users\Username\Projects\MyApp\
-
Use WSL2 for building instead of native Windows
📋 Full CMake Warning
CMake Warning in .../react-native-keyboard-controller/android/src/main/jni/CMakeLists.txt:
The object file directory
.../reactnativekeyboardcontroller_autolinked_build/CMakeFiles/react_codegen_reactnativekeyboardcontroller.dir/./
has 191 characters. The maximum full path to an object file is 250
characters (see CMAKE_OBJECT_PATH_MAX). Object file
.../RNKCKeyboardControllerViewShadowNode.cpp.o
cannot be safely placed under this directory.
🏷️ Labels
bug windows new-architecture fabric build-failure
🐛 Bug Report: Windows Build Fails - Path Exceeds 260 Character Limit
Summary
Android builds fail on Windows with New Architecture (Fabric) enabled due to generated file paths exceeding Windows' 260 character
MAX_PATHlimit.🔴 Error
📊 Path Analysis
reactnativekeyboardcontroller_autolinked_build/CMakeFiles/react_codegen_reactnativekeyboardcontroller.dir/C_/Users/Admin/Projects/BeingnexusNative/node_modules/react-native-keyboard-controller/common/cpp/react/renderer/components/reactnativekeyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.cpp.oRoot Cause
The namespace
reactnativekeyboardcontroller(32 chars) appears 4 times in the path, contributing ~128 characters.🖥️ Environment
📝 Reproduction Steps
gradle.properties:newArchEnabled=trueKeyboardProviderto App.tsx:✅ Expected Behavior
Build should complete successfully on Windows.
❌ Actual Behavior
Build fails with
Filename longer than 260 characterserror.💡 Suggested Fix
Option 1: Shorten Codegen Name (Recommended)
In
package.json, use a shorternamefor codegen:{ "codegenConfig": { "name": "rnkc", // Instead of "reactnativekeyboardcontroller" ... } }Option 2: Shorten Internal Paths
Restructure cpp files:
Option 3: Shorten File Names
The build also shows these deprecation warnings:
1. AndroidManifest
packageAttribute (Deprecated)2. Deprecated React Native APIs
LayoutShadowNode→ deprecatedReactShadowNodeImpl→ deprecatedMapBuilder→ Use Kotlin's built-in collectionsUIManagerType.DEFAULT→ UseLEGACYstatusBarColor→ deprecated in Android APIFLAG_FULLSCREEN→ deprecatedReactFeatureFlags→ UseReactNativeFeatureFlags🔧 Temporary Workarounds (For Users)
Enable Long Paths in Windows (requires admin + reboot):
Move project to shorter path:
Use WSL2 for building instead of native Windows
📋 Full CMake Warning
🏷️ Labels
bugwindowsnew-architecturefabricbuild-failure