tauri: [bug] V2 pnpm tauri android dev just hands and does nothing - Ubuntu 24.4.0

Describe the bug

pnpm Tauri android dev just hangs with no output or action. --verbose doesn’t assist.

Reproduction

pnpm create tauri-app --rc cd tauri-app pnpm i pnpm tauri android init pnpm tauri dev – builds and launches pnpm tauri android dev: hangs pnpm tauri android dev --open: opens android studio and will run the app after I open the emulator

Expected behavior

I would expect something to start compiling and then for the emulator to launch

Full tauri info output

[✔] Environment
    - OS: Ubuntu 24.4.0 x86_64 (X64)
    ✔ webkit2gtk-4.1: 2.44.3
    ✔ rsvg2: 2.58.0
    ✔ 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 (default)
    - node: 22.8.0
    - pnpm: 9.11.0
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.0.0-rc.15
    - tauri-build 🦀: 2.0.0-rc.12
    - wry 🦀: 0.43.1
    - tao 🦀: 0.30.2
    - @tauri-apps/api : 2.0.0-rc.5
    - @tauri-apps/cli : 2.0.0-rc.16

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.0-rc.3
    - @tauri-apps/plugin-shell : 2.0.0-rc.1

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

Stack trace

No response

Additional context

.zshrc exports export JAVA_HOME=/snap/android-studio/current/jbr export ANDROID_HOME=“$HOME/Android/Sdk” export NDK_HOME=“$ANDROID_HOME/ndk/$(ls -1 $ANDROID_HOME/ndk)”

Android studio: CompileCommand: exclude com/intellij/openapi/vfs/impl/FilePartNodeRoot.trieDescend bool exclude = true Android Studio Koala | 2024.1.1 Build #AI-241.15989.150.2411.11948838

Note that ‘pnpm tauri android dev --open’ starts compiling and then opens android studio.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I can confirm with @xdewx. It would seem the solution to the problem is to have some Android device (hardware or emulated) detected by Android Studio. Once that’s setup, the command npm run tauri android dev runs as intended and even works with multiple devices connected (a selection menu appears).

Here’s my recommendations:

  1. Update the documentation, specifically the “Quick Start” > “Prerequisites” > “Android” section. (https://tauri.app/start/prerequisites/#android) There should be description of how to setup an Android device, both physical hardware and emulated. At very least, the documentation could link to the respective pages on the Android Developer documentation (https://developer.android.com/studio/run/device) and (https://developer.android.com/studio/run/managing-avds). It is worth noting that the above works (see below), as well as opening up the Virtual Device Manager directly in Android Studio and running an AVD.
> ${ANDROID_HOME}/emulator/emulator -list-avds
> ${ANDROID_HOME}/emulator/emulator -avd ${AVD_NAME}
  1. The script behind the npm run tauri android dev command should be updated. As of now, the command only works if the Android device is already setup prior to running the command. Running the command and then starting an Android device does not stop the hanging. Either the command should periodically poll the status of Android devices, or it should fail immediately if none are detected (could be an option to better support CI/CD pipelines). If a periodic polling strategy is implemented, it should give some indicator that it is waiting for a device. Something along the lines of:
> npm run tauri android dev

> tauri-app@0.1.0 tauri
> tauri android dev

[INFO] Waiting for Android device to be connected... (see https://tauri.app/start/prerequisites/#android)

I can probably get both of these resolved if I find some time in the next couple of weeks, but someone else is certainly welcome to go right ahead!

I came across the same issue. Finally solved with the following steps:

  1. ${ANDROID_HOME}/emulator/emulator -list-avds
  2. ${ANDROID_HOME}/emulator/emulator -avd name from the first step
  3. pnpm tauri andorid dev

It seems that we need setup emulator first. Why does not offical document mention that?

To install the cli you currently need to use the --locked flag

cargo install tauri-cli --version "^2.0.0-rc" --locked

On first glance I don’t see why this started to happen ~yesterday - got one or two reports on discord as well. I don’t think it’s that important to figure out though as the --locked flag is always recommended for cargo install commands (if you saw commands without the flag in our docs, please tell me, i’ve been searching for it earlier today after seeing that nobody uses it)

Edit: Oh lol, it’s in the setup instructions, i’ll update that. If you see it anywhere else though, please reach out.