Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-android-build-nvm4w-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-cli': 'patch:bug'
---

Fix Android build error on Windows when using nvm4w (issue documented at #13892 [bug] [android] [windows] [cli] [build] Android Build Error: A problem occurred starting process 'command 'C:\nvm4w\nodejs\node.exe.cmd'' and Error: Cannot find module '...tauri' when using nvm4w). The BuildTask.kt template now includes robust fallback logic for Windows executable detection, preventing the "Cannot find module" and "node.exe.cmd" errors that occurred with nvm4w Node.js installations. The fix tries multiple Windows-specific fallbacks including .cmd, .bat extensions and cargo as a last resort.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ open class BuildTask : DefaultTask() {
runTauriCli(executable)
} catch (e: Exception) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
runTauriCli("$executable.cmd")
// Try different Windows-specific fallbacks
val fallbacks = listOf(
"$executable.cmd",
"$executable.bat",
"cargo.exe",
"cargo"
)

var lastException: Exception = e
for (fallback in fallbacks) {
try {
runTauriCli(fallback)
return
} catch (fallbackException: Exception) {
lastException = fallbackException
}
}
throw lastException
} else {
throw e;
}
Expand All @@ -32,7 +49,15 @@ open class BuildTask : DefaultTask() {
val rootDirRel = rootDirRel ?: throw GradleException("rootDirRel cannot be null")
val target = target ?: throw GradleException("target cannot be null")
val release = release ?: throw GradleException("release cannot be null")
val args = listOf({{quote-and-join tauri-binary-args}});

val baseArgs = listOf({{quote-and-join tauri-binary-args}});

// If we're using cargo as a fallback, we need to prepend "tauri" to the args
val args = if (executable.contains("cargo")) {
listOf("tauri") + baseArgs
} else {
baseArgs
}.toMutableList()

project.exec {
workingDir(File(project.projectDir, rootDirRel))
Expand Down