-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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] android dev - "Waiting for your frontend dev server to start on..." #9824
Comments
From the logs, it seems that Vite is only started on localhost and not on internal IPs, and that's why mobile dev server can't be found. You need something like this https://github.com/tauri-apps/create-tauri-app/blob/2e35db4af381a7955bd56fef8ad27ecc76b16151/templates/template-svelte/vite.config.js.lte#L19-L26
localhost is local to your computer which is different from the localhost of the android device, so it won't be accessible, this is why you need to expose your vite dev server on internal IPs so the android device can use on of these IPs to connect. I know the documentation is lacking on this atm but will be available on https://beta.tauri.app/start/frontend-configuration/vite/ before v2 hits stable. |
@amrbashir Thanks for the hints. There seem to be things used there that aren't in place with my installation. Firstly the
That gets a little further but I think this issue is due to migration from Tauri v1 because looking in a clean Tauri v2 app the vite.config.js is indeed like the one you suggested, whereas my migrated v1 app just loads the svelte plugin. So I guess there are a few things missing in the migrated project:
And possibly some other things. Can you suggest the further migration steps that might solve the above? I can't find an issue that covers this for migration so perhaps it should be re-opened or referenced in a new issue? |
you can ignore that, it is a template pre-processor in create-tauri-app, the snippet you showed above is correct
You will just need to install Then you can import it |
I want to build for non-mobile too, so if I hard-code for mobile that won't work. I'd like to migrate my v1 app fully to v2 beta, and some steps are incomplete. So while your suggestions may fix the Android problem I assume they will break my desktop builds. |
I see, you can just copy this vite config which handles both desktop and mobile import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { internalIpV4 } from "internal-ip";
// @ts-expect-error process is a nodejs global
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM);
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [svelte()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: mobile ? "0.0.0.0" : false,
hmr: mobile
? {
protocol: "ws",
host: await internalIpV4(),
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
})); |
Thanks for your help with this but I'm still getting the same error having pasted the above as it is in to vite.config.json:
|
the above vite example uses port |
Describe the bug
I've been working on a Tauri v1 project, and then decided to try v2 beta, so I also created a Tauri v2 project and had the hello world example working there (showing the 'greet' UI).
I then made a copy of my Tauri v1 project and have migrated it to v2 beta and have it working for desktop.
I then decided to try the
cargo tauri android dev
on the migrated project. I had some issues with it complaining about the app identifier because it contains '-' but eventually cleared those by deleting src-tauri/gen and re-doing cargo tauri android init.Now, when I do cargo tauri android dev, I get a strange result. Firstly, the emulator starts as normal, but shows the 'greet' example, not my app. And in the console I get the following:
I don't understand why it is showing the 'greet' example. http://192.168.43.141:5173/ is kindof correct in that this is the local IP of my machine, but I would expect it to us 'localhost'. But anyway, why is the dev server not starting?
I have my app working on desktop, and it feels like I'm very close to having it working on android, but I'm not sure what is going on here. I haven't done android development before so not sure what might cause this.
Reproduction
No response
Expected behavior
My app loads into the Android emulator.
Full
tauri info
outputStack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: