#How to use tauri mobile?

182 messages · Page 1 of 1 (latest)

lament portal
#

I'm trying to get tauri mobile to work for android but I seem to be getting errors. I followed all the steps on https://next--tauri.netlify.app/next/guides/getting-started/prerequisites/windows/#android.
I ran cargo mobile init and initialised the project to bevy-demo, but then cargo run creates these errors (first image)
Does anyone know how to fix this/if i got setup wrong? I'm actually trying to get this working with pnpm but I couldn't find how to get that working so I just tried it with cargo for now.

lament portal
odd sandal
#

Oh you're using that one

#

Update dependencies to those listed here

#

Then maybe try:

#

cargo mobile android dev

celest garden
#

Through pnpm, that command is pnpm tauri android init

odd sandal
#

You can install the cratesio version

#

cargo install tauri-cli --version "^2.0.0-alpha"

celest garden
#

You haven't installed Tauri with Cargo, so you're getting the error message that Cargo can't find the sub-command tauri.

odd sandal
#

Ye

#

Alpha

lament portal
#

Alright I'll have a try

odd sandal
#

That mobile project is uhh related but not release

lament portal
celest garden
#

If you use the alpha for create-tauri-app, it should do it for you.

lament portal
#

Alright

odd sandal
odd sandal
celest garden
odd sandal
#

Ohhh woww

#

So it inits mobile automatically?

celest garden
#

It looks like the first error you posted is an error in bevy, not Tauri. It looks like bevy implements winit for itself; does bevy have mobile support?

lament portal
#

its taken like 8 m to start 🙃 is this normal?

odd sandal
#

Idk i dont use bevy

lament portal
#

using pnpm rn

#

i connected it to my phone and i think its working but its just a black screen rn

#

nvm its not lmao

#

do u know what this means?

celest garden
lament portal
#

i think create-tauri-app already did that?

#

in vite.config.ts

celest garden
#

Yep.

#

It's weird that the connection would be getting refused then. Do you have a firewall setup?

lament portal
#

i dont think so, how do i check?

celest garden
#

If you didn't set it up, it shouldn't be a problem.

#

Windows has a default one but it's a pretty relaxed ruleset and hasn't caused any issues that I know of.

#

Do you have the Android emulator installed?

lament portal
#

i have android studio, not sure how to use it tho

#

pnpm tauri dev works fine

celest garden
#

And that's launching the emulator, not on a physical device?

lament portal
#

yeah

#

well just launching on my computer, not emulator

celest garden
#

It's an emulator that installed with AndroidStudio that emulates the Android runtime.

#

So long as it's on your computer screen and not a phone screen, then it should have access to your local network. This is a rather strange bug.

#

Do you have a GitHub repo that is public?

lament portal
#

yeah but not using mobile tauri

#

im currently just testing on whats given by tauri-create-app alpha

celest garden
#

Oh. So this isn't including bevy yet?

lament portal
#

this one is using svelte

celest garden
#

Just an empty project created by create-tauri-app?

lament portal
#

yep

celest garden
#

If you visit the IP in a browser, do you see any content?

#

If not, it means the server failed to start for some reason.

lament portal
#

using pnpm tauri dev it works on localhost:1420

#

also did pnpm tauri android open, it loaded android studio but idk how to emulate it

celest garden
#

Uh... ipconfig. Sorry, Windows and Linux have similar commands.

lament portal
#

do i need to run pnpm tauri android dev again first?

celest garden
#

No, your IP shouldn't change very often on a local network.

lament portal
celest garden
#

I'm trying to make sure that the IP fetched by the Node package internal-ip is one that you've been assigned.

#

So it's not a package bug. Weird that the emulator couldn't connect to it when the dev server is running.

#

What does the beforeDevCommand look like in your tauri.conf.json?

lament portal
#

pnpm dev

celest garden
#

It should have --hostname $HOST at the end to allow the hostname to change.

lament portal
#

do i change it to pnpm dev --hostname $HOST ?

celest garden
#

Yes.

celest garden
# lament portal yes

Since the server is running on this IP, it should change the hostname to match and allow the connection.

lament portal
#

does this warning mean something?

#

when i run pnpm tauri android dev

#

without --hostname

celest garden
#

Oh, you're using Vite, not Next.js, it means that Vite will automatically detect it.

#

Remove the --hostname $HOST again, my mistkae.

lament portal
#

i get this after it finishes compiling

celest garden
#

Does it normally give you that output?

lament portal
#

yeah every time i run it

celest garden
#

The mention of "Failed to read DnsConfig" is a little concerning.

#

You definitely ran rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android, right?

lament portal
#

yes

celest garden
#

Oh... I just spotted the problem. In your vite.config.ts, the port is 1421 but the mobile is expecting 1420.

lament portal
#

oh lmao ill try run it again

#

still doesn't work :(

#

btw opening tuari.localhost on my computer doesn't work either

celest garden
#

Do you open the IP directly or as tauri.localhost?

lament portal
#

tauri.localhost

#

oh

#

wtf

#

i turned off my public firewall and now it worked

#

uhhh

celest garden
#

Okay, that's really weird if you've never changed the default settings for it.

lament portal
#

do you know how to configure it so i don't need to turn off my firewall?

celest garden
#

Apparently the hrm setting in vite.config.ts should be a different port (1421), according to the example in the docs. Not sure why but should probably change it back.

lament portal
#

ah ok

celest garden
#

Are you using WIndows 10 or 11?

lament portal
#

lol this is popping up like every second now

#

windows 10

celest garden
#

If you search for Windows Defender Firewall, it should come up with a brick wall and a globe icon.

#

On the left, you should see a Turn Windows Defender Firewall on or off option.

lament portal
#

yep

celest garden
#

Inside that there will be a Block all incoming connections checkbox which is probably ticked for you.

#

If it's not, I'm not sure what is causing the problem.

lament portal
celest garden
#

Yeah, should look like that. Is that the settings you had already?

lament portal
#

yeah

celest garden
#

And you never saw a prompt about the app?

lament portal
#

i think there was a prompt when i opened android studio about adb.exe

celest garden
#

Yeah, that would probably have been it.

#

Did you leave it ticked for public networks?

lament portal
#

yeah, have it ticked

celest garden
#

Hm... there's two of them?

lament portal
#

i turned firewall back on and restarted, its not working again

#

should i maybe tick both adb.exe's?

celest garden
#

Check the paths for them first.

#

Click on either one and then Details.

lament portal
#

both of them are \appdata\local\android\sdk\platform-tools\adb.exe

celest garden
#

That's odd. Try ticking both then.

#

Considering both are ticked for public networks though, it should be allowed through.

lament portal
#

ticked both, still doesn't work

celest garden
#

If you run Resource Monitor, it should tell you what process is trying to create a network connection.

#

I have no idea what it could be other than NodeJS or adb.exe

lament portal
celest garden
#

The two Java processes are also using the network?

lament portal
#

oh adb just spiked a ton

celest garden
#

If you go to the Network tab, it should tell you what IPs they're asking for.

#

Under TCP Connections

#

It will have a lot of clutter in there but you would be looking for anything asking for the IP posted earlier.

lament portal
celest garden
#

Loopback is normal and shouldn't be getting blocked. It's more likely to be a different IP.

lament portal
#

all of them have a local address of 192.168.5.227 or IPv4 loopback

celest garden
#

Any ports you recognise, like 1420 or 1421?

#

Are you running this in a container at all, or is it just bare Windows?

lament portal
#

just windows

#

reran tauri android dev, a greyed out node.exe showed local port 1420 for a bit then disappeared

celest garden
#

Yeah, that's normal. Things disappear when there's no active connection. Listening Ports is the category below.

lament portal
#

ah oki

celest garden
#

Everything works fine with the firewall off, right?

lament portal
#

yep

celest garden
#

Hm... I'll try to replicate it on my end because I'm out of ideas on what it could be.

#

Once you whitelist something in the firewall, unless you've got a very angry anti-virus, it shouldn't be an issue.

lament portal
#

oh i got it

celest garden
#

Anti-virus...?

lament portal
#

had to tick both node.js javascript runtimes

celest garden
#

Oh.

#

Two runtimes is unusual unless you've got multiple versions installed?

lament portal
#

uhh wtf i just ran it again and this popped up

lament portal
#

both of the nodes point to the same exe

celest garden
#

Oh, maybe it's inbound and outbound.

#

Hm... doesn't look like it. Maybe just a weird thing that Windows did during an update or something.

lament portal
#

its all good now

#

tho i still get that wall of warnings

lament portal
celest garden
#

That's probably the debug output from the emulator. Might have been enabled in Tauri to find issues and found it's way into a release version.

lament portal
#

hmmm live updates aren't working

#

changing lib.rs recompiles a bunch of stuff and works but changing js files doesn't update on my phone

#

oh uh now it keeps on recompiling even tho nothing changed

#

its fine i think i can figure it out for now, tysm for your help @celest garden !

celest garden
#

No problem. I'm glad we figured it out, it was a strange issue.

grand rain
#

Hii! I have the same issue. My app cant connect to localhost (on real device). In this thread i didnt find how you solved it. My app works fine on emulated device as well.
"The web page at https://tauri.localhost/ could not be loaded because: net::ERR_CONNECTION_REFUSED"
@lament portal did you fix it after all?

grand rain
lament portal
#

You can check whether the issue is with the firewall by turning it off completely on settings first

grand rain
#

at the end of the day we need running app on real device, did release build help?

lament portal
#

I was never using an emulated one

grand rain
#

OMG

#

YooooHoooooo

#

i got it. portmaster was blocking my pc server.
I thoutght it transfers all files to device. But instead pc starting to be a server

#

@lament portal Thank you alot!