tauri-apps / tauri

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

[bug] Error No available Android Emulator detected #8598

Closed Raduc4 closed 7 months ago

Raduc4 commented 8 months ago

Describe the bug

I have a bearbone project generated with cargo create-tauri-app --alpha (v2.0.0.alpha.20) that I want to run on android emulator. Everything runs without errors but the app doesn't start in the emulator that is running already. It is hanging at Opening Android Studio and that's it.

Removing gen folder and doing again cargo tauri android init didn't help.

alu@alu ~/p/citadel_workspace> cargo tauri android dev
        Info Using 192.168.0.108 to access the development server.
       Error No available Android Emulator detected
     Running BeforeDevCommand (`bun run dev`)
$ vite

  VITE v5.0.11  ready in 269 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: http://192.168.0.108:1420/
        Info detected host target triple "x86_64-unknown-linux-gnu"
   Compiling wry v0.35.2
   Compiling tauri v2.0.0-alpha.20
   Compiling citadel_workspace v0.0.0 (/home/alu/proj/citadel_workspace/src-tauri)
   Compiling tauri-runtime-wry v1.0.0-alpha.8
   Compiling tauri-plugin-shell v2.0.0-alpha.6
    Finished dev [unoptimized + debuginfo] target(s) in 7.60s
        Info symlinking lib "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" in jniLibs dir "/home/alu/proj/citadel_workspace/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a"
        Info "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" requires shared lib "libandroid.so"
        Info "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" requires shared lib "libdl.so"
        Info "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" requires shared lib "liblog.so"
        Info "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" requires shared lib "libm.so"
        Info "/home/alu/proj/citadel_workspace/src-tauri/target/aarch64-linux-android/debug/libcitadel_workspace_lib.so" requires shared lib "libc.so"
        Info Opening Android Studio

Reproduction

cargo create-tauri-app --alpha (v2.0.0.alpha.20) cd /new_project

set env variables IN MY CASE $ANDROID_HOME = ~alu/Android $JAVA_HOME = /usr/lib/jvm/java-19-openjdk-amd64/ $NDK_HOME = /home/alu/Android/Sdk/ndk/26.1.10909125/

cargo tauri android init cargo tauri android dev

Expected behavior

Start the app in the android emulator

Full tauri info output

[✔] Environment
    - OS: Ubuntu 22.04 X64
    ✔ webkit2gtk-4.1: 2.42.3
    ✔ rsvg2: 2.52.5
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 20.11.0
    - npm: 10.2.4
    - bun: 1.0.22

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.20
    - tauri-build [RUST]: 2.0.0-alpha.13
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.24.0
    - tauri-cli [RUST]: 2.0.0-alpha.20
    - @tauri-apps/api [NPM]: 2.0.0-alpha.13
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.20

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

No response

Additional context

cargo tauri android build Building the app goes well but when tried to install it on my phone it didn't even wanted to start the install.

olivierlemasle commented 8 months ago

What is the output of ${ANDROID_HOME}/emulator/emulator -list-avds ?

Raduc4 commented 8 months ago

alu@alu ~> $ANDROID_HOME/emulator/emulator -list-avds Medium_Phone_API_32

olivierlemasle commented 7 months ago

It seems you solved this issue by updating Tauri to its latest alpha version, right? (https://discord.com/channels/616186924390023171/1047150269156294677/threads/1195829683569299627)

Sorry, I looked at the latest Tauri code and found the emulator -list-avds command was executed and parsed; I did not think then that it was not the same code in your Tauri version :blush:

frozzen10 commented 6 months ago

I am trying to make it work on WSL. I have a problem to launch mobile app too, maybe someone will help what am I missing, full tauri info output (similar to @Raduc4)

[✔] Environment
    - OS: Ubuntu 22.04 X64
    ✔ webkit2gtk-4.1: 2.42.4
    ✔ rsvg2: 2.52.5
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.11.0
    - npm: 10.2.4
    - bun: 1.0.26

[-] Packages
    - tauri [RUST]: 2.0.0-beta.2
    - tauri-build [RUST]: 2.0.0-beta.1
    - wry [RUST]: 0.35.2
    - tao [RUST]: 0.25.0
    - @tauri-apps/api [NPM]: 2.0.0-beta.0
    - @tauri-apps/cli [NPM]: 2.0.0-beta.1

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

My env variables:

echo $ANDROID_HOME 
/home/adrian/.android
echo $JAVA_HOME 
/usr/lib/jvm/java-11-openjdk-amd64
echo $NDK_HOME 
/home/adrian/.android/ndk/25.0.8775105

I have created app with Bunx + Vite commands used:

bunx create-tauri-app --alpha

with options:

  1. app-name
  2. TypeScript / JavaScript
  3. bun
  4. React
  5. TypeScript
  6. y
    cd app-name

and then here is output of install and init commands:

bun install
bun install v1.0.26 (c75e768a)

 + @tauri-apps/cli@2.0.0-beta.1
 + @types/react@18.2.56
 + @types/react-dom@18.2.19
 + @vitejs/plugin-react@4.2.1
 + internal-ip@7.0.0 (v8.0.0 available)
 + typescript@5.3.3
 + vite@5.1.3
 + @tauri-apps/api@2.0.0-beta.0
 + @tauri-apps/plugin-shell@2.0.0-beta.0
 + react@18.2.0
 + react-dom@18.2.0
bun run tauri android init
 $ tauri android init
        Info "/home/adrian/app-name/node_modules/.bin/tauri" relative to "/home/adrian/app-name/src-tauri" is "../node_modules/.bin/tauri"
Generating Android Studio project...
        Info "/home/adrian/app-name/src-tauri" relative to "/home/adrian/app-name/src-tauri/gen/android/app_name" is "../../../"
victory: Project generated successfully!
    Make cool apps! 🌻 🐕 🎉

but after run of bun run tauri android that is output:

$ tauri android dev
       Error No available Android Emulator detected
        Info Using 172.23.213.67 to access the development server.
     Running BeforeDevCommand (`bun run dev`)
$ vite

  VITE v5.1.3  ready in 134 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: http://172.23.213.67:1420/
        Info detected host target triple "x86_64-unknown-linux-gnu"
    Updating crates.io index
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling siphasher v0.3.11
   Compiling ppv-lite86 v0.2.17
   Compiling syn v1.0.109
   Compiling serde v1.0.196
   Compiling getrandom v0.1.16
   Compiling parking_lot_core v0.9.9
   Compiling hashbrown v0.14.3
   Compiling equivalent v1.0.1
   Compiling proc-macro-hack v0.5.20+deprecated
   Compiling winnow v0.5.40
   Compiling thiserror v1.0.57
   Compiling once_cell v1.19.0
   Compiling phf_shared v0.10.0
   Compiling phf_shared v0.8.0
   Compiling fnv v1.0.7
   Compiling strsim v0.10.0
   Compiling convert_case v0.4.0
   Compiling ident_case v1.0.1
   Compiling smallvec v1.13.1
   Compiling phf_shared v0.11.2
   Compiling typenum v1.17.0
   Compiling new_debug_unreachable v1.0.4
   Compiling scopeguard v1.2.0
   Compiling serde_json v1.0.113
   Compiling byteorder v1.5.0
   Compiling semver v1.0.22
   Compiling version_check v0.9.4
   Compiling mac v0.1.1
   Compiling ryu v1.0.17
   Compiling lock_api v0.4.11
   Compiling indexmap v2.2.3
   Compiling itoa v1.0.10
   Compiling precomputed-hash v0.1.1
   Compiling tinyvec_macros v0.1.1
   Compiling tinyvec v1.6.0
   Compiling indexmap v1.9.3
   Compiling futf v0.1.5
   Compiling bitflags v1.3.2
   Compiling log v0.4.20
   Compiling dtoa v1.0.9
   Compiling utf-8 v0.7.6
   Compiling tendril v0.4.3
   Compiling dtoa-short v0.3.4
   Compiling quote v1.0.35
   Compiling generic-array v0.14.7
   Compiling phf v0.10.1
   Compiling unicode-bidi v0.3.15
   Compiling alloc-no-stdlib v2.0.4
   Compiling matches v0.1.10
   Compiling stable_deref_trait v1.2.0
   Compiling camino v1.1.6
   Compiling syn v2.0.49
   Compiling nodrop v0.1.14
   Compiling itoa v0.4.8
   Compiling hashbrown v0.12.3
   Compiling percent-encoding v2.3.1
   Compiling servo_arc v0.1.1
   Compiling getrandom v0.2.12
   Compiling form_urlencoded v1.2.1
   Compiling rand_core v0.6.4
   Compiling rand_core v0.5.1
   Compiling uuid v1.7.0
   Compiling alloc-stdlib v0.2.2
   Compiling fxhash v0.2.1
   Compiling rand_chacha v0.3.1
   Compiling rand_chacha v0.2.2
   Compiling rand_pcg v0.2.1
   Compiling parking_lot v0.12.1
   Compiling unicode-normalization v0.1.22
   Compiling thin-slice v0.1.1
   Compiling schemars v0.8.16
   Compiling rand v0.7.3
   Compiling memchr v2.7.1
   Compiling rand v0.8.5
   Compiling cfb v0.7.3
   Compiling brotli-decompressor v2.5.1
   Compiling same-file v1.0.6
   Compiling dyn-clone v1.0.16
   Compiling anyhow v1.0.80
   Compiling walkdir v2.4.0
   Compiling idna v0.5.0
   Compiling dunce v1.0.4
   Compiling glob v0.3.1
   Compiling heck v0.4.1
   Compiling infer v0.15.0
   Compiling phf_generator v0.8.0
   Compiling phf_generator v0.10.0
   Compiling phf_codegen v0.8.0
   Compiling phf_generator v0.11.2
   Compiling string_cache_codegen v0.5.2
   Compiling phf_codegen v0.10.0
   Compiling selectors v0.22.0
   Compiling brotli v3.4.0
   Compiling cc v1.0.83
   Compiling pin-project-lite v0.2.13
   Compiling markup5ever v0.11.0
   Compiling dirs-sys-next v0.1.2
   Compiling crc32fast v1.4.0
   Compiling jni-sys v0.3.0
   Compiling simd-adler32 v0.3.7
   Compiling dirs-next v2.0.0
   Compiling slab v0.4.9
   Compiling crossbeam-utils v0.8.19
   Compiling adler v1.0.2
   Compiling futures-core v0.3.30
   Compiling miniz_oxide v0.7.2
   Compiling mio v0.8.10
   Compiling socket2 v0.5.5
   Compiling num_cpus v1.16.0
   Compiling tracing-core v0.1.32
   Compiling cesu8 v1.1.0
   Compiling raw-window-handle v0.5.2
   Compiling darling_core v0.20.6
   Compiling flate2 v1.0.28
   Compiling tracing v0.1.40
   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 memoffset v0.7.1
   Compiling httparse v1.8.0
   Compiling cfg_aliases v0.1.1
   Compiling same-file v0.1.3
   Compiling futures-task v0.3.30
   Compiling serde_derive_internals v0.26.0
   Compiling pin-utils v0.1.0
   Compiling futures-sink v0.3.30
   Compiling walkdir v1.0.7
   Compiling wry v0.35.2
   Compiling png v0.17.13
   Compiling crossbeam-channel v0.5.11
   Compiling digest v0.10.7
   Compiling cpufeatures v0.2.12
   Compiling ndk-context v0.1.1
   Compiling tauri-runtime v2.0.0-beta.1
   Compiling try-lock v0.2.5
   Compiling base64 v0.21.7
   Compiling want v0.3.1
   Compiling sha2 v0.10.8
   Compiling ico v0.3.0
   Compiling futures-channel v0.3.30
   Compiling instant v0.1.12
   Compiling tower-service v0.3.2
   Compiling httpdate v1.0.3
   Compiling lazy_static v1.4.0
   Compiling raw-window-handle v0.6.0
   Compiling tauri-runtime-wry v2.0.0-beta.1
   Compiling nix v0.26.4
   Compiling aho-corasick v1.1.2
   Compiling is-docker v0.2.0
   Compiling encoding_rs v0.8.33
   Compiling ipnet v2.9.0
   Compiling regex-syntax v0.8.2
   Compiling mime v0.3.17
   Compiling sync_wrapper v0.1.2
   Compiling is-wsl v0.4.0
   Compiling state v0.6.0
   Compiling static_assertions v1.1.0
   Compiling pathdiff v0.2.1
   Compiling open v4.2.0
   Compiling os_pipe v1.1.5
   Compiling shared_child v1.0.0
   Compiling serde_derive v1.0.196
   Compiling thiserror-impl v1.0.57
   Compiling cssparser-macros v0.6.1
   Compiling darling_macro v0.20.6
   Compiling phf_macros v0.11.2
   Compiling phf_macros v0.8.0
   Compiling cssparser v0.27.2
   Compiling html5ever v0.26.0
   Compiling derive_more v0.99.17
   Compiling ctor v0.2.6
   Compiling schemars_derive v0.8.16
   Compiling futures-macro v0.3.30
   Compiling tao-macros v0.1.2
   Compiling serialize-to-javascript-impl v0.1.1
   Compiling regex-automata v0.4.5
   Compiling darling v0.20.6
   Compiling serde_repr v0.1.18
   Compiling serde_with_macros v3.6.1
   Compiling phf v0.11.2
   Compiling phf v0.8.0
   Compiling futures-util v0.3.30
   Compiling regex v1.10.3
   Compiling serde_spanned v0.6.5
   Compiling toml_datetime v0.6.3
   Compiling string_cache v0.8.7
   Compiling cargo-platform v0.1.7
   Compiling url v2.5.0
   Compiling serde_with v3.6.1
   Compiling bytes v1.5.0
   Compiling toml_edit v0.19.15
   Compiling toml_edit v0.20.2
   Compiling rustc_version v0.4.0
   Compiling http v0.2.11
   Compiling combine v4.6.6
   Compiling tokio v1.36.0
   Compiling serde_urlencoded v0.7.1
   Compiling treediff v4.0.3
   Compiling cargo_metadata v0.18.1
   Compiling json-patch v1.2.0
   Compiling http-body v0.4.6
   Compiling kuchikiki v0.8.2
   Compiling toml v0.8.2
   Compiling toml v0.7.8
   Compiling proc-macro-crate v1.3.1
   Compiling serialize-to-javascript v0.1.1
   Compiling tauri-utils v2.0.0-beta.1
   Compiling embed-resource v2.4.1
   Compiling cargo_toml v0.17.2
   Compiling tauri-winres v0.1.1
   Compiling num_enum_derive v0.5.11
   Compiling tokio-util v0.7.10
   Compiling h2 v0.3.24
   Compiling num_enum v0.5.11
   Compiling ndk v0.7.0
   Compiling jni v0.21.1
   Compiling tauri-build v2.0.0-beta.1
   Compiling tauri-plugin v2.0.0-beta.1
   Compiling tauri-codegen v2.0.0-beta.1
   Compiling hyper v0.14.28
   Compiling tao v0.25.0
   Compiling reqwest v0.11.24
   Compiling tauri v2.0.0-beta.2
   Compiling tauri-plugin-shell v2.0.0-beta.0
   Compiling tauri-macros v2.0.0-beta.1
   Compiling app-name v0.0.0 (/home/adrian/app-name/src-tauri)
    Finished dev [unoptimized + debuginfo] target(s) in 40.06s
        Info symlinking lib "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" in jniLibs dir "/home/adrian/app-name/src-tauri/gen/android/app/src/main/jniLibs/arm64-v8a"
        Info "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" requires shared lib "libandroid.so"
        Info "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" requires shared lib "libdl.so"
        Info "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" requires shared lib "liblog.so"
        Info "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" requires shared lib "libm.so"
        Info "/home/adrian/app-name/src-tauri/target/aarch64-linux-android/debug/libapp_name_lib.so" requires shared lib "libc.so"
        Info Opening Android Studio
       Error Launch failed: No such file or directory (os error 2)

and nothing happens... I am really stuck. When I am using ${ANDROID_HOME}/emulator/emulator -list-avds nothing is shown but I don't know what to do to change this. Can someone help me?

I was using step by step guide from this: https://github.com/tauri-apps/wry/blob/dev/MOBILE.md I am windows user but I am runing this on WSL so I was doing what is described for Linux / WSL. I haven't add this: For WSL: you also need to get ADB to connect to your emulator that is running on Windows

export WSL_HOST="192.168.1.2" # Run ipconfig in windows to get your computer IP export ADB_SERVER_SOCKET=tcp:$WSL_HOST:5037

because I am not sure about what is this for.

Raduc4 commented 6 months ago

Do you have any emulator setted up? It also may be because you use WSL, run a ubuntu machine and see if it compiles and opens

frozzen10 commented 6 months ago

I don't think so, how can I do that?