Skip to content

Commit 7300001

Browse files
authored
fix(android): allow overriding CMake version for Windows long-path builds (#265)
Fixes #263 On Windows, the Android build fails when CMake object-file paths exceed `MAX_PATH` (260 chars). The NDK default CMake (3.22.1) can't handle the deeply-nested paths from Nitrogen's generated sources. This is a [known issue across React Native libraries that use CMake](https://docs.swmansion.com/react-native-reanimated/docs/guides/building-on-windows/). Adds support for the `CMAKE_VERSION` env var (same as Reanimated) so users can opt into a newer CMake (e.g. 3.31.6) that handles long paths.
1 parent ed3f65c commit 7300001

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export default {
131131

132132
</details>
133133

134+
## Building on Windows (CMake long-path failures)
135+
136+
On Windows, the Android build can fail with `ninja: error: mkdir(CMakeFiles/rive.dir/...): No such file or directory` due to the Windows `MAX_PATH` (260-character) limit. This is a [known issue across React Native libraries that use CMake](https://docs.swmansion.com/react-native-reanimated/docs/guides/building-on-windows/). Set `CMAKE_VERSION` to a newer version (e.g. `3.31.6`) before building — see the Reanimated docs for full setup instructions.
137+
134138
## Error Handling
135139

136140
All Rive operations can be wrapped in try/catch blocks for error handling, for example, loading a file:

android/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ android {
6969
externalNativeBuild {
7070
cmake {
7171
path "CMakeLists.txt"
72+
// On Windows the NDK default CMake (3.22.1) fails when object-file
73+
// paths exceed MAX_PATH (260 chars). Set CMAKE_VERSION=3.31.6 to fix.
74+
// See: https://docs.swmansion.com/react-native-reanimated/docs/guides/building-on-windows/
75+
def cmakeVersionOverride = System.getenv("CMAKE_VERSION")
76+
if (cmakeVersionOverride) {
77+
version cmakeVersionOverride
78+
}
7279
}
7380
}
7481

0 commit comments

Comments
 (0)