Open AClon314 opened 5 months ago
Temporary solution:
before:
@TaskAction
fun assemble() {
val executable = """C:\Program Files\nodejs\node.exe""";
after:
@TaskAction
fun assemble() {
val executable = """C:\Users\Administrator\.bun\bin\bun.exe""";
In My macos, use bun
would cause another error. I am using the following settings , it works for me
@TaskAction
fun assemble() {
val executable = """cargo-tauri""";
I have this problem, what should I do to fix this problem?
bun run tauri android dev
$ tauri android dev
(Redmi Note ) with target "aarch64-linux-android"
Running BeforeDevCommand (bun run dev
)
Info Using to access the development server.
$ nuxt dev
Info detected host target triple "x86_64-pc-windows-msvc"
Nuxt 3.11.2 with Nitro 2.9.6 4:38:35 PM
4:38:35 PM
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
Compiling wry v0.40.1
Compiling tauri v2.0.0-beta.22
Compiling app v0.1.0 (C:*\src-tauri)
Compiling tauri-runtime-wry v2.0.0-beta.18
➜ DevTools: press Shift + Alt + D in the browser (v1.3.3) 4:38:37 PM
ℹ Compiled plugins/client.mjs in 511.23ms 4:38:37 PM
ℹ Compiled types/plugins.d.ts in 527.99ms 4:38:37 PM
Finished dev
profile [unoptimized + debuginfo] target(s) in 4.68s
Info symlinking lib "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" in jniLibs dir "C:\\src-tauri\gen/android\app/src/main/jniLibs/arm64-v8a"
Info "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" requires shared lib "libandroid.so"
Info "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" requires shared lib "libdl.so"
Info "C:\*\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" requires shared lib "liblog.so"
Info "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" requires shared lib "libm.so"
Info "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so" requires shared lib "libc.so"
Info symlink at "C:\\src-tauri\gen/android\app/src/main/jniLibs/arm64-v8a\libapp_lib.so" points to "C:\\src-tauri\target\aarch64-linux-android\debug\libapp_lib.so"
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module 'C:*\src-tauri\tauri' at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) at Module._load (node:internal/modules/cjs/loader:986:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) at node:internal/main/run_main_module:28:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }
Node.js v20.13.1 e: C:*\src-tauri\gen\android\app\src\main\java\com\tauri\dev\generated\Logger.kt: (86, 14): Unresolved reference: BuildConfig
FAILURE: Build completed with 2 failures.
What went wrong: Execution failed for task ':app:rustBuildArm64Debug'.
A problem occurred starting process 'command 'node.cmd''
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
What went wrong: Execution failed for task ':app:compileArm64DebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction Compilation error. See log for more details
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.6/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 2s error: script "dev" exited with code 255 Error Failed to assemble APK: command ["C:\\src-tauri\gen/android\gradlew.bat", "--project-dir", "C:\\src-tauri\gen/android"] exited with code 1: command ["C:\\src-tauri\gen/android\gradlew.bat", "--project-dir", "C:\\src-tauri\gen/android"] exited with code 1 error: script "tauri" exited with code 1
This is how it worked out for me
Change runtime from node to bun src-tauri\gen\android\buildSrc\src\main\java\com\tauri\tauri_app\kotlin\BuildTask.kt
before:
@TaskAction
fun assemble() {
val executable = """node""";
after:
@TaskAction
fun assemble() {
val executable = """bun""";
I found a solution that worked using npx
.
The error happens because the Node.js executable can't find the tauri
module when running the BuildTask
in Gradle.
Using npx
ensures that the correct version of the tauri
CLI will be used, whether it's installed locally in the project or needs to be temporarily downloaded.
Ensure @tauri-apps/cli@next
is installed:
npm install -g @tauri-apps/cli@next
or
yarn add @tauri-apps/cli@next
Update your BuildTask.kt
:
Replace the following lines in your existing BuildTask.kt
implementation. This version uses npx
to handle the Tauri CLI command:
Before:
@TaskAction
fun assemble() {
val executable = """C:\Program Files\nodejs\\node.exe""";
try {
runTauriCli(executable)
} catch (e: Exception) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
runTauriCli("$executable.cmd")
} else {
throw e;
}
}
}
After:
@TaskAction
fun assemble() {
val tauriCommand = if (Os.isFamily(Os.FAMILY_WINDOWS)) "npx.cmd" else "npx"
try {
runTauriCli(tauriCommand)
} catch (e: Exception) {
throw GradleException("Failed to run Tauri CLI", e)
}
}
By using npx
, the script ensures that the tauri
command is correctly found.
Describe the bug
https://discord.com/channels/616186924390023171/1222636353070694510 https://discord.com/channels/616186924390023171/1216097197716934816
android build failed at around: <=======---->EXECUTE 60%
Reproduction
Try to do a clean init
windows powershell:
Expected behavior
android build success
Full
tauri info
outputStack trace
Additional context
I ran
tauri android init
today. Before running this on my old project, everything is ok. after update the tauri to alpha.14, this build failure occured.