tauri
tauri copied to clipboard
[bug] Build for Android fails with error: "Cannot find module '\project\src-tauri\tauri' "
Describe the bug
https://discord.com/channels/616186924390023171/1222636353070694510 https://discord.com/channels/616186924390023171/1216097197716934816
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:rustBuildX86_64Debug'.
> A problem occurred starting process 'command 'd:\Program Files\nodejs\node.exe.cmd''
android build failed at around: <=======---->EXECUTE 60%
Reproduction
Try to do a clean init
windows powershell:
rustup update
# update or install globally:
pnpm i -g yarn @tauri-apps/cli@next
mkdir testit ; cd testit
tauri plugin init
# hit enter to comfire com.plugin.testit
tauri plugin android init
# a must-do init, otherwise would get error
tauri android init
yarn intall
cd examples/tauri-app ; yarn install ; cd ../..
tauri android dev
cd .
Expected behavior
android build success
Full tauri info
output
[✔] Environment
- OS: Windows 10.0.22631 X64
✔ WebView2: 120.0.2210.91
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
✔ cargo: 1.77.2 (e52e36006 2024-03-26)
✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.11.1
- pnpm: 8.15.7
- yarn: 1.22.22
- npm: 10.2.4
[-] Packages
- tauri [RUST]: 2.0.0-beta.15
- tauri-build [RUST]: 2.0.0-beta.12
- wry [RUST]: 0.39.1
- tao [RUST]: 0.27.0
- @tauri-apps/api [NPM]: 2.0.0-beta.8
- @tauri-apps/cli [NPM]: 2.0.0-beta.13
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- bundler: Rollup
Stack trace
warning package.json: No license field
error Command "intall" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
(base) PS D:\Documents\Code\rust\testit> cd examples/tauri-app ; yarn install ; cd ../..
yarn install v1.22.22
warning ..\..\package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
warning @sveltejs/vite-plugin-svelte > magic-string > [email protected]: Please use @jridgewell/sourcemap-codec instead
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 10.44s.
(base) PS D:\Documents\Code\rust\testit> tauri android dev
Info Detected connected device: Pixel_3a_API_34_extension_level_7_x86_64 (sdk_gphone64_x86_64) with target "x86_64-linux-android"
Info Using 10.210.125.102 to access the development server.
Running BeforeDevCommand (`yarn dev`)
yarn run v1.22.22
warning ..\..\package.json: No license field
$ vite
Forced re-optimization of dependencies
VITE v3.2.10 ready in 1606 ms
➜ Local: http://localhost:1420/
➜ Network: http://10.***.***.102:1420/
➜ Network: http://192.168.***.***:1420/
✘ [ERROR] [plugin vite:dep-scan] Failed to resolve entry for package "tauri-plugin-testit-api". The package may have incorrect main/module/exports specified in its package.json.
node_modules/esbuild/lib/main.js:1336:21:
1336 │ let result = await callback({
╵ ^
at packageEntryFailure (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:34107:11)
at resolvePackageEntry (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:34104:5)
at tryNodeResolve (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:33842:20)
at Context.resolveId (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:33602:28)
at Object.resolveId (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:40539:46)
at async resolve (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:40763:26)
at async file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:40937:34
at async requestCallbacks.on-resolve (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:1336:22)
at async handleRequest (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:706:13)
This error came from the "onResolve" callback registered here:
node_modules/esbuild/lib/main.js:1260:20:
1260 │ let promise = setup({
╵ ^
at setup (file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:40927:19)
at handlePlugins (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:1260:21)
at buildOrServeImpl (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:951:5)
at Object.buildOrServe (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:759:5)
at D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:2096:17
at new Promise (<anonymous>)
at Object.build (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:2095:14)
at build (D:\Documents\Code\rust\testit\examples\tauri-app\node_modules\esbuild\lib\main.js:1942:51)
at file:///D:/Documents/Code/rust/testit/examples/tauri-app/node_modules/vite/dist/node/chunks/dep-372dab03.js:40711:46
The plugin "vite:dep-scan" was triggered by this import
script:D:/Documents/Code/rust/testit/examples/tauri-app/src/App.svelte?id=0:3:26:
3 │ import { execute } from 'tauri-plugin-testit-api'
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~
Build failed with 1 error:
node_modules/esbuild/lib/main.js:1336:21: ERROR: [plugin: vite:dep-scan] Failed to resolve entry for package "tauri-plugin-testit-api". The package may have incorrect main/module/exports specified in its package.json.
Info detected host target triple "x86_64-pc-windows-msvc"
Updating crates.io index
Compiling proc-macro2 v1.0.81
Compiling unicode-ident v1.0.12
Compiling cfg-if v1.0.0
Compiling siphasher v0.3.11
Compiling ppv-lite86 v0.2.17
Compiling syn v1.0.109
Compiling serde v1.0.198
Compiling autocfg v1.2.0
Compiling libc v0.2.153
Compiling getrandom v0.1.16
Compiling parking_lot_core v0.9.9
Compiling getrandom v0.2.14
Compiling hashbrown v0.14.3
Compiling phf_shared v0.10.0
Compiling rand_core v0.6.4
Compiling phf_shared v0.8.0
Compiling rand_chacha v0.3.1
Compiling proc-macro-hack v0.5.20+deprecated
Compiling equivalent v1.0.1
Compiling thiserror v1.0.59
Compiling rand v0.8.5
Compiling lock_api v0.4.11
Compiling indexmap v2.2.6
Compiling winnow v0.5.40
Compiling windows_x86_64_msvc v0.48.5
Compiling convert_case v0.4.0
Compiling fnv v1.0.7
Compiling once_cell v1.19.0
Compiling rand_core v0.5.1
Compiling phf_generator v0.10.0
Compiling strsim v0.10.0
Compiling ident_case v1.0.1
Compiling rand_chacha v0.2.2
Compiling rand_pcg v0.2.1
Compiling phf_codegen v0.10.0
Compiling smallvec v1.13.2
Compiling phf_shared v0.11.2
Compiling quote v1.0.36
Compiling rand v0.7.3
Compiling windows-targets v0.48.5
Compiling typenum v1.17.0
Compiling winapi v0.3.9
Compiling phf_generator v0.11.2
Compiling syn v2.0.60
Compiling string_cache_codegen v0.5.2
Compiling new_debug_unreachable v1.0.6
Compiling tinyvec_macros v0.1.1
Compiling scopeguard v1.2.0
Compiling semver v1.0.22
Compiling version_check v0.9.4
Compiling phf_generator v0.8.0
Compiling byteorder v1.5.0
Compiling phf_codegen v0.8.0
Compiling serde_json v1.0.116
Compiling tinyvec v1.6.0
Compiling selectors v0.22.0
Compiling markup5ever v0.11.0
Compiling precomputed-hash v0.1.1
Compiling mac v0.1.1
Compiling generic-array v0.14.7
Compiling itoa v1.0.11
Compiling ryu v1.0.17
Compiling futf v0.1.5
Compiling parking_lot v0.12.1
Compiling indexmap v1.9.3
Compiling bitflags v1.3.2
Compiling unicode-bidi v0.3.15
Compiling percent-encoding v2.3.1
Compiling utf-8 v0.7.6
Compiling unicode-normalization v0.1.23
Compiling log v0.4.21
Compiling dtoa v1.0.9
Compiling memchr v2.7.2
Compiling dtoa-short v0.3.4
Compiling tendril v0.4.3
Compiling form_urlencoded v1.2.1
Compiling phf v0.10.1
Compiling aho-corasick v1.1.3
Compiling idna v0.5.0
Compiling unic-common v0.9.0
Compiling camino v1.1.6
Compiling matches v0.1.10
Compiling itoa v0.4.8
Compiling regex-syntax v0.8.3
Compiling stable_deref_trait v1.2.0
Compiling nodrop v0.1.14
Compiling unic-char-range v0.9.0
Compiling alloc-no-stdlib v2.0.4
Compiling hashbrown v0.12.3
Compiling unic-char-property v0.9.0
Compiling alloc-stdlib v0.2.2
Compiling servo_arc v0.1.1
Compiling unic-ucd-version v0.9.0
Compiling darling_core v0.20.8
Compiling fxhash v0.2.1
Compiling uuid v1.8.0
Compiling thin-slice v0.1.1
Compiling serde_derive_internals v0.26.0
Compiling winapi-util v0.1.6
Compiling schemars v0.8.16
Compiling unic-ucd-ident v0.9.0
Compiling cfb v0.7.3
Compiling same-file v1.0.6
Compiling brotli-decompressor v2.5.1
Compiling dyn-clone v1.0.17
Compiling anyhow v1.0.82
Compiling cc v1.0.95
Compiling walkdir v2.5.0
Compiling infer v0.15.0
Compiling glob v0.3.1
Compiling regex-automata v0.4.6
Compiling brotli v3.5.0
Compiling dunce v1.0.4
Compiling windows-sys v0.48.0
Compiling pin-project-lite v0.2.14
Compiling regex v1.10.4
Compiling vswhom-sys v0.1.2
Compiling futures-core v0.3.30
Compiling dirs-sys-next v0.1.2
Compiling slab v0.4.9
Compiling vswhom v0.1.0
Compiling jni-sys v0.3.0
Compiling heck v0.4.1
Compiling serde_derive v1.0.198
Compiling thiserror-impl v1.0.59
Compiling cssparser-macros v0.6.1
Compiling darling_macro v0.20.8
Compiling phf_macros v0.11.2
Compiling ctor v0.2.8
Compiling phf_macros v0.8.0
Compiling cssparser v0.27.2
Compiling html5ever v0.26.0
Compiling derive_more v0.99.17
Compiling darling v0.20.8
Compiling schemars_derive v0.8.16
Compiling winreg v0.52.0
Compiling serde_with_macros v3.7.0
Compiling simd-adler32 v0.3.7
Compiling crc32fast v1.4.0
Compiling phf v0.11.2
Compiling phf v0.8.0
Compiling dirs-next v2.0.0
Compiling socket2 v0.5.6
Compiling mio v0.8.11
Compiling num_cpus v1.16.0
Compiling crossbeam-utils v0.8.19
Compiling adler v1.0.2
Compiling miniz_oxide v0.7.2
Compiling futures-macro v0.3.30
Compiling tracing-core v0.1.32
Compiling pin-utils v0.1.0
Compiling httparse v1.8.0
Compiling futures-task v0.3.30
Compiling cesu8 v1.1.0
Compiling tracing v0.1.40
Compiling flate2 v1.0.28
Compiling futures-util v0.3.30
Compiling block-buffer v0.10.4
Compiling crypto-common v0.1.6
Compiling fdeflate v0.3.4
Compiling ndk-sys v0.4.1+23.1.7779620
Compiling pin-project-internal v1.1.5
Compiling raw-window-handle v0.5.2
Compiling raw-window-handle v0.6.1
Compiling try-lock v0.2.5
Compiling want v0.3.1
Compiling png v0.17.13
Compiling digest v0.10.7
Compiling crossbeam-channel v0.5.12
Compiling tao-macros v0.1.2
Compiling futures-channel v0.3.30
Compiling ndk-context v0.1.1
Compiling tower-layer v0.3.2
Compiling cpufeatures v0.2.12
Compiling wry v0.39.1
Compiling serde_spanned v0.6.5
Compiling toml_datetime v0.6.3
Compiling toml_edit v0.20.2
Compiling toml_edit v0.19.15
Compiling bytes v1.6.0
Compiling string_cache v0.8.7
Compiling url v2.5.0
Compiling cargo-platform v0.1.8
Compiling serde_with v3.7.0
Compiling treediff v4.0.3
Compiling urlpattern v0.2.0
Compiling json-patch v1.2.0
Compiling cargo_metadata v0.18.1
Compiling toml v0.8.2
Compiling http v1.1.0
Compiling rustc_version v0.4.0
Compiling toml v0.7.8
Compiling kuchikiki v0.8.2
Compiling embed-resource v2.4.2
Compiling cargo_toml v0.17.2
Compiling tauri-utils v2.0.0-beta.12
Compiling tauri-winres v0.1.1
Compiling proc-macro-crate v1.3.1
Compiling tokio v1.37.0
Compiling combine v4.6.7
Compiling http-body v1.0.0
Compiling dpi v0.1.1
Compiling pin-project v1.1.5
Compiling tower-service v0.3.2
Compiling tauri-runtime v2.0.0-beta.12
Compiling sha2 v0.10.8
Compiling num_enum_derive v0.5.11
Compiling ico v0.3.0
Compiling instant v0.1.12
Compiling lazy_static v1.4.0
Compiling tauri-build v2.0.0-beta.12
Compiling tauri-plugin v2.0.0-beta.12
Compiling base64 v0.22.0
Compiling hyper v1.3.1
Compiling tower v0.4.13
Compiling futures-sink v0.3.30
Compiling jni v0.21.1
Compiling tauri-runtime-wry v2.0.0-beta.12
Compiling base64 v0.21.7
Compiling hyper-util v0.1.3
Compiling num_enum v0.5.11
Compiling tokio-util v0.7.10
Compiling ndk v0.7.0
Compiling tauri-codegen v2.0.0-beta.12
Compiling http-body-util v0.1.1
Compiling serde_urlencoded v0.7.1
Compiling serialize-to-javascript-impl v0.1.1
Compiling mime v0.3.17
Compiling ipnet v2.9.0
Compiling sync_wrapper v0.1.2
Compiling serialize-to-javascript v0.1.1
Compiling reqwest v0.12.4
Compiling tao v0.27.0
Compiling serde_repr v0.1.19
Compiling state v0.6.0
Compiling tauri v2.0.0-beta.15
Compiling tauri-plugin-testit v0.0.0 (D:\Documents\Code\rust\testit)
Compiling tauri-macros v2.0.0-beta.12
Compiling tauri-app v0.0.0 (D:\Documents\Code\rust\testit\examples\tauri-app\src-tauri)
Finished dev [unoptimized + debuginfo] target(s) in 1m 49s
Info symlinking lib "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" in jniLibs dir "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\gen/android\\app/src/main/jniLibs/x86_64"
Info "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" requires shared lib "libandroid.so"
Info "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" requires shared lib "libdl.so"
Info "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" requires shared lib "liblog.so"
Info "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" requires shared lib "libm.so"
Info "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so" requires shared lib "libc.so"
Info symlink at "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\gen/android\\app/src/main/jniLibs/x86_64\\libtauri_app_lib.so" points to "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\target\\x86_64-linux-android\\debug\\libtauri_app_lib.so"
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module 'D:\Documents\Code\rust\testit\examples\tauri-app\src-tauri\tauri'
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.11.1
w: C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tauri-2.0.0-beta.15\mobile\android\src\main\java\app\tauri\plugin\PluginMethodData.kt: (11, 23): Parameter 'methodDecorator' is never used
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:rustBuildX86_64Debug'.
> A problem occurred starting process 'command 'd:\Program Files\nodejs\node.exe.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
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.
See https://docs.gradle.org/8.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 13s
Error Failed to assemble APK: command ["D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\gen/android\\gradlew.bat", "--project-dir", "D:\\Documents\\Code\\rust\\testit\\examples\\tauri-app\\src-tauri\\gen/android"] exited with code 1
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.
Temporary solution:
Change runtime from node.js to bun
- src-tauri\gen\android\buildSrc\src\main\java\com\tauri\tauri_app\kotlin\BuildTask.kt
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""";