tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.53k stars 2.58k forks source link

[bug] Failed to assemble APK #11502

Open FabricSoul opened 1 month ago

FabricSoul commented 1 month ago

Describe the bug

Failed to build the app for Android with Svelte template

Reproduction

cargo create-tauri-app Choose Typescript/Javascript pnpm as package manager Svelte as UI template Typescript cd tauri-app pnpm i cargo tauri android init cargo tauri android dev

Expected behavior

build and run successfully

Full tauri info output

[✔] Environment
    - OS: Arch Linux Rolling Release x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.46.2
    ✔ rsvg2: 2.59.1
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.9.0
    - pnpm: 9.12.1
    - yarn: 1.22.22
    - npm: 10.9.0

[-] Packages
    - tauri 🦀: 2.0.6
    - tauri-build 🦀: 2.0.2
    - wry 🦀: 0.46.3
    - tao 🦀: 0.30.3
    - tauri-cli 🦀: 2.0.4
    - @tauri-apps/api : 2.0.3
    - @tauri-apps/cli : 2.0.5

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

Finished `dev` profile [unoptimized + debuginfo] target(s) in 36.51s
    Info symlinking lib "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" in jniLibs dir "/home/fabric/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/x86_64"
    Info "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libandroid.so"
    Info "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libdl.so"
    Info "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "liblog.so"
    Info "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libm.so"
    Info "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libc.so"
    Info symlink at "/home/fabric/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/x86_64/libtauri_app_lib.so" points to "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so"

FAILURE: Build failed with an exception.

* Where:
Settings file '/home/fabric/tauri-app/src-tauri/gen/android/settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'android'.
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67

* 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.

BUILD FAILED in 427ms
    Error Failed to assemble APK: command ["/home/fabric/tauri-app/src-tauri/gen/android/gradlew", "--project-dir", "/home/fabric/tauri-app/src-tauri/gen/android"] exited with code 1:

Additional context

No response

amrbashir commented 4 weeks ago

Can you run with --verbose and post the result?

FabricSoul commented 3 weeks ago
Debug [ignore::gitignore] opened gitignore file: /tmp/.gitignore
    Debug [globset] built glob set; 0 literals, 3 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
    Debug [ignore::gitignore] opened gitignore file: /home/fabric/tauri-app/.gitignore
    Debug [globset] glob converted to regex: Glob { glob: "**/.env.*", re: "(?-u)^(?:/?|.*/)\\.env\\.[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([RecursivePrefix, Literal('.'), Literal('e'), Literal('n'), Literal('v'), Literal('.'), ZeroOrMore]) }
    Debug [globset] glob converted to regex: Glob { glob: "**/vite.config.js.timestamp-*", re: "(?-u)^(?:/?|.*/)vite\\.config\\.js\\.timestamp\\-[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([RecursivePrefix, Literal('v'), Literal('i'), Literal('t'), Literal('e'), Literal('.'), Literal('c'), Literal('o'), Literal('n'), Literal('f'), Literal('i'), Literal('g'), Literal('.'), Literal('j'), Literal('s'), Literal('.'), Literal('t'), Literal('i'), Literal('m'), Literal('e'), Literal('s'), Literal('t'), Literal('a'), Literal('m'), Literal('p'), Literal('-'), ZeroOrMore]) }
    Debug [globset] glob converted to regex: Glob { glob: "**/vite.config.ts.timestamp-*", re: "(?-u)^(?:/?|.*/)vite\\.config\\.ts\\.timestamp\\-[^/]*$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([RecursivePrefix, Literal('v'), Literal('i'), Literal('t'), Literal('e'), Literal('.'), Literal('c'), Literal('o'), Literal('n'), Literal('f'), Literal('i'), Literal('g'), Literal('.'), Literal('t'), Literal('s'), Literal('.'), Literal('t'), Literal('i'), Literal('m'), Literal('e'), Literal('s'), Literal('t'), Literal('a'), Literal('m'), Literal('p'), Literal('-'), ZeroOrMore]) }
    Debug [globset] built glob set; 3 literals, 4 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 3 regexes
    Debug [ignore::gitignore] opened gitignore file: /home/fabric/tauri-app/src-tauri/.gitignore
    Debug [globset] built glob set; 2 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
    Info [tauri_cli::mobile::android] Starting emulator Medium_Phone_API_35
INFO    | Android emulator version 35.2.10.0 (build_id 12414864) (CL:N/A)
INFO    | Graphics backend: gfxstream
INFO    | Found systemPath /home/fabric/Android/Sdk/system-images/android-35/google_apis_playstore/x86_64/
INFO    | Duplicate loglines will be removed, if you wish to see each individual line launch with the -log-nofilter flag.
WARNING | File System is not ext4, disable QuickbootFileBacked feature
INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_posture_requested(int) ((null):0, (null))

INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_posture_selection_dialog() ((null):0, (null))

INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_resizable_requested(PresetEmulatorSizeType) ((null):0, (null))

INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_resizable_dialog() ((null):0, (null))

INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_sleep_timer_done() ((null):0, (null))

INFO    | Warning: QMetaObject::connectSlotsByName: No matching signal for on_unfold_timer_done() ((null):0, (null))

INFO    | Storing crashdata in: /tmp/android-fabric/emu-crash-35.2.10.db, detection is enabled for process: 428787
WARNING | Your GPU drivers may have a bug. Switching to software rendering.
library_mode swangle_indirect gpu mode swangle_indirect
INFO    | emuglConfig_get_vulkan_hardware_gpu: Using gpu 'NVIDIA GeForce RTX 3070 Ti' for vulkan support

INFO    | Initializing hardware OpenGLES emulation support
android_startOpenglesRenderer: gpu infoI1101 22:46:35.493746  428787 FrameBuffer.cpp:260] Raised nofile soft limit to 4096.
I1101 22:46:35.493818  428787 HealthMonitor.cpp:279] HealthMonitor disabled.
I1101 22:46:35.493866  428787 VulkanDispatch.cpp:78] initIcdPaths: ICD set to 'swiftshader', using Swiftshader ICD
I1101 22:46:35.493904  428787 VulkanDispatch.cpp:47] Setting ICD filenames for the loader = /home/fabric/Android/Sdk/emulator/qemu/linux-x86_64/lib64/vulkan/vk_swiftshader_icd.json:/home/fabric/Android/Sdk/emulator/lib64/vulkan/vk_swiftshader_icd.json
I1101 22:46:35.493981  428787 VulkanDispatch.cpp:137] Added library: /home/fabric/Android/Sdk/emulator/lib64/vulkan/libvulkan.so
W1101 22:46:35.502860  428787 VkCommonOperations.cpp:1169] Selecting Vulkan device: SwiftShader Device (Subzero), Version: 1.3.0
initialize: Supports id properties, got a vulkan device UUID
I1101 22:46:35.545654  428787 VkCommonOperations.cpp:1531] Initializing VkEmulation features:
I1101 22:46:35.545671  428787 VkCommonOperations.cpp:1532]     glInteropSupported: false
I1101 22:46:35.545676  428787 VkCommonOperations.cpp:1533]     useDeferredCommands: true
I1101 22:46:35.545679  428787 VkCommonOperations.cpp:1535]     createResourceWithRequirements: true
I1101 22:46:35.545682  428787 VkCommonOperations.cpp:1536]     useVulkanComposition: false
I1101 22:46:35.545685  428787 VkCommonOperations.cpp:1537]     useVulkanNativeSwapchain: false
I1101 22:46:35.545689  428787 VkCommonOperations.cpp:1538]     enable guestRenderDoc: false
I1101 22:46:35.545692  428787 VkCommonOperations.cpp:1539]     ASTC LDR emulation mode: 2
I1101 22:46:35.545695  428787 VkCommonOperations.cpp:1540]     enable ETC2 emulation: true
I1101 22:46:35.545698  428787 VkCommonOperations.cpp:1541]     enable Ycbcr emulation: false
I1101 22:46:35.545701  428787 VkCommonOperations.cpp:1542]     guestVulkanOnly: false
I1101 22:46:35.545705  428787 VkCommonOperations.cpp:1543]     useDedicatedAllocations: false
I1101 22:46:35.549874  428787 FrameBuffer.cpp:522] Graphics Adapter Vendor Google (Google Inc.)
I1101 22:46:35.549881  428787 FrameBuffer.cpp:523] Graphics Adapter Android Emulator OpenGL ES Translator (Google SwiftShader)
I1101 22:46:35.549885  428787 FrameBuffer.cpp:524] Graphics API Version OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)
I1101 22:46:35.549888  428787 FrameBuffer.cpp:525] Graphics API Extensions GL_OES_EGL_sync GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_standard_derivatives GL_OES_texture_npot GL_OES_rgb8_rgba8 GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888
I1101 22:46:35.549895  428787 FrameBuffer.cpp:526] Graphics Device Extensions N/A
INFO    | Sending adb public key [QAAAABeQDt1ZWNiX+njQ5X2gJXzwPXcbioCMCKS6KAFxnzEbQrEsCWEmG4b/PcUBWNH23n8dRRDw5fw9ergl3z8FLTWIoWl+A/qH3RVYMB1dqOpoZpQOrO2CAEg5TFax4LfBsCDMpgDfotZHIgj03hlQvNO0BuXUe6Uw2tsTiKNVPfYpziVRRWNCc3JZWnX7XSzW96gHYDK1WHpCzMpvweKOSNt9Rm/A80PtwsuawiVF2Gv3YfTYp8oZBTJI3Eu7OadO9/KT+Dqrhnz+NCx8V5rye6/j0uU2Pd10HzxM7fIHaKsBqFVIzoTe2XPpcCutA8Q2MfxpvF7WAdqDgy2ION39uHJk5JGkIlwH8oJdH63A+GnudMKwcbWymuD0jLaNFykom650breONREDMKBNLoFgjhCt418pDs7+hBIyc+eWT4NBvoiz4y3xKXHX3+FxNuFX70Mpr4YTYtmcUPp9BiApYw+HvdyBr6CBRvVrUGUDX8rJLsDtMeG/JKweUieHmMho8s5V8GyfU5PUxYSB0eYuM3cfNXe7XYbB7YC2ceORjlI3blAfzUektq1QDFuNNXfIzxOnhwE7bwDV3x/pYQolNk3D1DddMcc5wgiP/C0Tot+bY5IG3595EPBetXg+72mgzUTMG6czQO9WSVgvKYxyqodrkpbXLOtQtDU730Yexk27VU7sBgEAAQA= fabric@unknown]
WARNING: cannnot unmap ptr 0x7884aea01000 as it is in the protected range from 0x78842ea00000 to 0x7884aec00000
INFO    | Monitoring duration of emulator setup.
WARNING | The emulator now requires a signed jwt token for gRPC access! Use the -grpc flag if you really want an open unprotected grpc port
INFO    | Using security allow list from: /home/fabric/Android/Sdk/emulator/lib/emulator_access.json
WARNING | *** Basic token auth should only be used by android-studio ***
INFO    | The active JSON Web Key Sets can be found here: /run/user/1000/avd/running/428787/jwks/f2df3a19-1132-4ffe-a38c-4882cc87d629/active.jwk
INFO    | Scanning /run/user/1000/avd/running/428787/jwks/f2df3a19-1132-4ffe-a38c-4882cc87d629 for jwk keys.
INFO    | Started GRPC server at 127.0.0.1:8554, security: Local, auth: +token
INFO    | Advertising in: /run/user/1000/avd/running/pid_428787.ini
INFO    | Qemu slirp is disabled.
I1101 22:46:35.727233  428838 FrameBuffer.cpp:2894] Setting display: 0 configuration to: 1080x2400, dpi: 420x420
I1101 22:46:35.727252  428838 FrameBuffer.cpp:2907] setDisplayActiveConfig 0
INFO    | OpenGL Vendor=[Google (Google Inc.)]
INFO    | OpenGL Renderer=[Android Emulator OpenGL ES Translator (Google SwiftShader)]
INFO    | OpenGL Version=[OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)]
INFO    | Loading snapshot 'default_boot'...
INFO    | Activated packet streamer for bluetooth emulation
    Info [tauri_cli::mobile::android] Waiting for emulator to start...
    Info [tauri_cli::mobile::android] Waiting for emulator to start...
INFO    | Successfully loaded snapshot 'default_boot'
INFO    | OpenGL Vendor=[Google (Google Inc.)]
INFO    | OpenGL Renderer=[Android Emulator OpenGL ES Translator (Google SwiftShader)]
INFO    | OpenGL Version=[OpenGL ES 3.0 (OpenGL ES 3.0 SwiftShader 4.0.0.1)]
E1101 22:46:40.220667  429105 FrameBuffer.cpp:3619] Failed to find ColorBuffer:0
E1101 22:46:40.836769  429107 FrameBuffer.cpp:3619] Failed to find ColorBuffer:0
    Info [tauri_cli::mobile::android] Detected connected device: Medium_Phone_API_35 (sdk_gphone64_x86_64) with target "x86_64-linux-android"
    Running [tauri_cli::dev] BeforeDevCommand (`pnpm dev`)

> tauri-app@0.1.0 dev /home/fabric/tauri-app
> vite dev

  VITE v5.4.10  ready in 736 ms

  ➜  Local:   http://localhost:1420/
   Compiling wry v0.46.3
   Compiling tauri v2.0.6
   Compiling tauri-plugin-shell v2.0.2
   Compiling tauri-app v0.1.0 (/home/fabric/tauri-app/src-tauri)
   Compiling tauri-runtime-wry v2.1.2
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 7.26s
    Info [cargo_mobile2::android::jnilibs] symlinking lib "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" in jniLibs dir "/home/fabric/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/x86_64"
    Info [cargo_mobile2::android::ndk] "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libandroid.so"
    Info [cargo_mobile2::android::ndk] "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libdl.so"
    Info [cargo_mobile2::android::ndk] "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "liblog.so"
    Info [cargo_mobile2::android::ndk] "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libm.so"
    Info [cargo_mobile2::android::ndk] "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so" requires shared lib "libc.so"
    Info [cargo_mobile2::android::jnilibs] symlink at "/home/fabric/tauri-app/src-tauri/gen/android/app/src/main/jniLibs/x86_64/libtauri_app_lib.so" points to "/home/fabric/tauri-app/src-tauri/target/x86_64-linux-android/debug/libtauri_app_lib.so"
Initialized native services in: /home/fabric/.gradle/native
Initialized jansi services in: /home/fabric/.gradle/native

Welcome to Gradle 8.9!

Here are the highlights of this release:
 - Enhanced Error and Warning Messages
 - IDE Integration Improvements
 - Daemon JVM Information

For more details see https://docs.gradle.org/8.9/release-notes.html

Received JVM installation metadata from '/usr/lib/jvm/java-23-openjdk': {JAVA_HOME=/usr/lib/jvm/java-23-openjdk, JAVA_VERSION=23, JAVA_VENDOR=Arch Linux, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=23, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=23, VM_VENDOR=Arch Linux, OS_ARCH=amd64}
Removing 0 daemon stop events from registry
Starting a Gradle Daemon (subsequent builds will be faster)
Starting process 'Gradle build daemon'. Working directory: /home/fabric/.gradle/daemon/8.9 Command: /usr/lib/jvm/java-23-openjdk/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /home/fabric/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a/gradle-8.9/lib/gradle-daemon-main-8.9.jar -javaagent:/home/fabric/.gradle/wrapper/dists/gradle-8.9-bin/90cnw93cvbtalezasaz0blq0a/gradle-8.9/lib/agents/gradle-instrumentation-agent-8.9.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.9
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 2.701 secs.
The client will now receive all logging from the daemon (pid: 430220). The daemon log file: /home/fabric/.gradle/daemon/8.9/daemon-430220.out.log
Starting build in new daemon [memory: 2 GiB]
Using 12 worker leases.
Received JVM installation metadata from '/usr/lib/jvm/java-23-openjdk': {JAVA_HOME=/usr/lib/jvm/java-23-openjdk, JAVA_VERSION=23, JAVA_VENDOR=Arch Linux, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=23, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=23, VM_VENDOR=Arch Linux, OS_ARCH=amd64}
Watching the file system is configured to be enabled if available
Now considering [/home/fabric/tauri-app/src-tauri/gen/android] as hierarchies to watch
Now considering [/home/fabric/tauri-app/src-tauri/gen/android/buildSrc, /home/fabric/tauri-app/src-tauri/gen/android] as hierarchies to watch
File system watching is active
Starting Build
Caching disabled for Groovy DSL script compilation (dsl) because:
  Build cache is disabled
  Not worth caching.
Compiling script '/home/fabric/tauri-app/src-tauri/gen/android/tauri.settings.gradle' using BuildScriptTransformer.

FAILURE: Build failed with an exception.

* Where:
Settings file '/home/fabric/tauri-app/src-tauri/gen/android/settings.gradle' line: 3

* What went wrong:
A problem occurred evaluating settings 'android'.
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 9s
VCS Checkout Cache (/home/fabric/tauri-app/src-tauri/gen/android/.gradle/vcs-1) removing files not accessed on or after Fri Oct 25 22:47:02 EDT 2024.
VCS Checkout Cache (/home/fabric/tauri-app/src-tauri/gen/android/.gradle/vcs-1) cleanup deleted 0 files/directories.
VCS Checkout Cache (/home/fabric/tauri-app/src-tauri/gen/android/.gradle/vcs-1) cleaned up in 0.006 secs.
    Error [tauri_cli] Failed to assemble APK: command ["/home/fabric/tauri-app/src-tauri/gen/android/gradlew", "--project-dir", "/home/fabric/tauri-app/src-tauri/gen/android"] exited with code 1:
MonsieurLazar commented 3 weeks ago

I have the same problem with SvelteKit.

MonsieurLazar commented 3 weeks ago

It was fixed by adding tauri to my package.json

"scripts": {
  "tauri": "tauri",
  "dev": "vite dev",
  "build": "vite build",
  "preview": "vite preview",
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
kingraphaii commented 4 days ago

For me this was an issue with incompatible gradle & java versions. The default tauri config used latest gradle, at this moment 8.11 and I had jdk ver 23. I ended up dowgrading to 8.10 You can get a better idea of which versions are compatible with each other on the gradle release pages.