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.
#How to use tauri mobile?
182 messages · Page 1 of 1 (latest)
Try:
cargo tauri android dev
Oh you're using that one
Update dependencies to those listed here
Then maybe try:
cargo mobile android dev
Through pnpm, that command is pnpm tauri android init
You can install the cratesio version
cargo install tauri-cli --version "^2.0.0-alpha"
You haven't installed Tauri with Cargo, so you're getting the error message that Cargo can't find the sub-command tauri.
Alright I'll have a try
That mobile project is uhh related but not release
Is the project initialisation the same as create-tauri-app?
If you use the alpha for create-tauri-app, it should do it for you.
Oh is there a different one I should be using?
Alright
Ye- so it's:
cargo create-tauri-app
[cargo tauri android init]
cargo tauri android dev
Wha- the blog didn't mention the alpha.
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?
its taken like 8 m to start 🙃 is this normal?
Idk i dont use bevy
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?
on my phone it says "The web page at https://tauri.localhost/ could not be loaded because: net::ERR_CONNECTION_REFUSED"
For the dev server on mobile, you need to give it your local IP (https://next--tauri.netlify.app/next/mobile/development/configuration#frontend-configuration).
Yep.
It's weird that the connection would be getting refused then. Do you have a firewall setup?
i dont think so, how do i check?
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?
And that's launching the emulator, not on a physical device?
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?
yeah but not using mobile tauri
im currently just testing on whats given by tauri-create-app alpha
Oh. So this isn't including bevy yet?
this one is using svelte
Just an empty project created by create-tauri-app?
yep
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.
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
If you open a cmd window and run ifconfig, do you see this IP in the list?
Uh... ipconfig. Sorry, Windows and Linux have similar commands.
do i need to run pnpm tauri android dev again first?
No, your IP shouldn't change very often on a local network.
yes
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?
pnpm dev
It should have --hostname $HOST at the end to allow the hostname to change.
do i change it to pnpm dev --hostname $HOST ?
Yes.
Since the server is running on this IP, it should change the hostname to match and allow the connection.
gives "CACError: Unknown option --hostname"
does this warning mean something?
when i run pnpm tauri android dev
without --hostname
Oh, you're using Vite, not Next.js, it means that Vite will automatically detect it.
Remove the --hostname $HOST again, my mistkae.
i get this after it finishes compiling
Does it normally give you that output?
yeah every time i run it
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?
yes
Oh... I just spotted the problem. In your vite.config.ts, the port is 1421 but the mobile is expecting 1420.
oh lmao ill try run it again
still doesn't work :(
btw opening tuari.localhost on my computer doesn't work either
Do you open the IP directly or as tauri.localhost?
tauri.localhost
oh
wtf
i turned off my public firewall and now it worked
uhhh
Okay, that's really weird if you've never changed the default settings for it.
do you know how to configure it so i don't need to turn off my firewall?
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.
ah ok
Are you using WIndows 10 or 11?
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.
yep
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.
Yeah, should look like that. Is that the settings you had already?
yeah
And you never saw a prompt about the app?
i think there was a prompt when i opened android studio about adb.exe
Yeah, that would probably have been it.
Did you leave it ticked for public networks?
yeah, have it ticked
Hm... there's two of them?
i turned firewall back on and restarted, its not working again
should i maybe tick both adb.exe's?
both of them are \appdata\local\android\sdk\platform-tools\adb.exe
That's odd. Try ticking both then.
Considering both are ticked for public networks though, it should be allowed through.
ticked both, still doesn't work
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
The two Java processes are also using the network?
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.
Loopback is normal and shouldn't be getting blocked. It's more likely to be a different IP.
all of them have a local address of 192.168.5.227 or IPv4 loopback
Any ports you recognise, like 1420 or 1421?
Are you running this in a container at all, or is it just bare Windows?
just windows
reran tauri android dev, a greyed out node.exe showed local port 1420 for a bit then disappeared
Yeah, that's normal. Things disappear when there's no active connection. Listening Ports is the category below.
Everything works fine with the firewall off, right?
yep
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.
oh i got it
Anti-virus...?
had to tick both node.js javascript runtimes
uhh wtf i just ran it again and this popped up
idk a lot of the apps in here have two
both of the nodes point to the same exe
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.
nvm my phone just disconnected so it emulated instead
its all good now
tho i still get that wall of warnings
this
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.
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 !
No problem. I'm glad we figured it out, it was a strange issue.
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?
yes, pretty much
Yeah the issue for mine was that the firewall wasn't set up properly, went to resource monitor to change a bunch of settings until it worked
You can check whether the issue is with the firewall by turning it off completely on settings first
yeah. i mean. U fixed it on your pc. But it should be still failing on your phone, isnt it? At the end you moved over using real device to emulated one and it worked, but it didnt fix the issue with running app on actual device. How did you handle that?
at the end of the day we need running app on real device, did release build help?
No it fixed it on my phone as well somehow
I was never using an emulated one