Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] tauri android dev doesn't work OOB on real devices (can't connect to localhost server) #11137

Closed
FabianLars opened this issue Sep 25, 2024 · 0 comments
Assignees
Labels
platform: Android status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@FabianLars
Copy link
Member

FabianLars commented Sep 25, 2024

Describe the bug

https://discord.com/channels/616186924390023171/986184094050316358/1285544267854647296
https://discord.com/channels/616186924390023171/1282867292216234006

tauri android dev doesn't work in a plain create-tauri-app out of the box on a real device (did not test emulator) because the app won't be able to connect to the localhost server

Reproduction

  1. connect real device (didn't test emulator)
  2. follow prereqs guide(s)
  3. Create tauri app
  4. tauri android init
  5. tauri android dev
  6. be sad :(
  7. update vite's server.host setting to 0.0.0.0 and restart
  8. be happy :)

Expected behavior

The templates should work out of the box, or the docs should mention the prereqs i may be missing.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 129.0.2792.52
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.17.0
    - pnpm: 9.10.0
    - npm: 10.8.2

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

[-] Plugins
    - tauri-plugin-fs 🦀: 2.0.0-rc.5
    - @tauri-apps/plugin-fs : 2.0.0-rc.0 (outdated, latest: 2.0.0-rc.2)
    - tauri-plugin-shell 🦀: 2.0.0-rc.3
    - @tauri-apps/plugin-shell : 2.0.0-rc.1

[-] App
    - build-type: bundle
    - CSP: default-src 'self'; image-src data:
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - bundler: Vite

Stack trace

No response

Additional context

https://discord.com/channels/616186924390023171/986184094050316358/1285544267854647296
https://discord.com/channels/616186924390023171/1282867292216234006
(same links as above)

p.s. i am not the only one with this issue but i think it's not an issue for everyone either (may be real device vs emulator then)

@FabianLars FabianLars added type: bug status: needs triage This issue needs to triage, applied to new issues platform: Android labels Sep 25, 2024
@FabianLars FabianLars moved this to Backlog in 2.0 Stable Sep 25, 2024
lucasfernog added a commit that referenced this issue Oct 1, 2024
this changes the `android dev` port forwarding (that is actually handled by the `android-studio-script` command - triggered by our Gradle plugin) with some enhancements:

- make the whole process more resilient by checking if the port was actually forwarded and rerunning the `adb reverse` command until it tells us the forward is ready
- if the `adb devices` list is empty, retry a few times (waiting a few seconds) to tolerate devices being booted - slows down "raw builds" (Build Project Android Studio menu for instance) that shouldn't happen often anyway - if you're running `android dev` you're usually running the app on a device instead of simply testing builds
@lucasfernog lucasfernog self-assigned this Oct 1, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in 2.0 Stable Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: Android status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
Status: Done
Development

No branches or pull requests

2 participants