tauri
tauri copied to clipboard
[bug] App won't launch on android emulator
Describe the bug
Tauri doesn't launch Android app inside emulator.
Reproduction
- Create a Tauri app with the new mobile alpha
- Install Android Studio and create an emulator
- Launch
tauri android dev
- Emulator opens but app doesn't appear inside
Expected behavior
The app should be visible after the emulator is launched.
Platform and versions
Environment › OS: Fedora 37.0.0 X64 › Node.js: 19.0.0 › npm: 8.19.2 › pnpm: Not installed! › yarn: Not installed! › rustup: 1.25.1 › rustc: 1.65.0 › cargo: 1.65.0 › Rust toolchain: stable-x86_64-unknown-linux-gnu
Packages › @tauri-apps/cli [NPM]: 2.0.0-alpha.0 › @tauri-apps/api [NPM]: 2.0.0-alpha.0 › tauri [RUST]: 2.0.0-alpha.0, › tauri-build [RUST]: 2.0.0-alpha.0, › tao [RUST]: 0.15.6, › wry [RUST]: 0.23.3,
App › build-type: bundle › CSP: unset › distDir: ../dist › devPath: http://localhost:3000/ › framework: React (Next.js) › bundler: Webpack
App directory structure ├─ public ├─ prisma ├─ node_modules ├─ .git ├─ .github ├─ src-tauri ├─ src └─ .next
Stack trace
❯ npm run tauri android dev --verbose
npm verb cli /home/arcanist/.nvm/versions/node/v19.0.0/bin/node /usr/local/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 2ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:/home/arcanist/Documents/Coding/test/my-t3-app/.npmrc Completed in 1ms
npm timing config:load:project Completed in 5ms
npm timing config:load:file:/home/arcanist/.npmrc Completed in 0ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:/home/arcanist/.nvm/versions/node/v19.0.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 2ms
npm timing config:load Completed in 17ms
npm timing npm:load:configload Completed in 17ms
npm timing npm:load:mkdirpcache Completed in 6ms
npm timing npm:load:mkdirplogs Completed in 1ms
npm verb title npm run tauri android dev
npm verb argv "run" "tauri" "android" "dev" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 2ms
npm timing config:load:flatten Completed in 4ms
npm timing npm:load:display Completed in 10ms
npm verb logfile logs-max:10 dir:/home/arcanist/.npm/_logs
npm verb logfile /home/arcanist/.npm/_logs/2022-12-10T23_12_01_576Z-debug-0.log
npm timing npm:load:logFile Completed in 8ms
npm timing npm:load:timers Completed in 1ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 46ms
> [email protected] tauri
> tauri android dev
Running BeforeDevCommand (`npm run dev`)leted in 46ms
npm verb cli /home/arcanist/.nvm/versions/node/v19.0.0/bin/node /usr/local/bin/npm
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 3ms
npm timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
npm timing config:load:builtin Completed in 1ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:/home/arcanist/Documents/Coding/test/my-t3-app/.npmrc Completed in 0ms
npm timing config:load:project Completed in 5ms
npm timing config:load:file:/home/arcanist/.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:/home/arcanist/.nvm/versions/node/v19.0.0/etc/npmrc Completed in 0ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 2ms
npm timing config:load:credentials Completed in 2ms
npm timing config:load:setEnvs Completed in 2ms
npm timing config:load Completed in 21ms
npm timing npm:load:configload Completed in 21ms
npm timing npm:load:mkdirpcache Completed in 8ms
npm timing npm:load:mkdirplogs Completed in 1ms
npm verb title npm run dev
npm verb argv "run" "dev"
npm timing npm:load:setTitle Completed in 2ms
npm timing config:load:flatten Completed in 5ms
npm timing npm:load:display Completed in 11ms
npm verb logfile logs-max:10 dir:/home/arcanist/.npm/_logs
npm verb logfile /home/arcanist/.npm/_logs/2022-12-10T23_12_03_521Z-debug-0.log
npm timing npm:load:logFile Completed in 8ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 53msoad Completed in 46ms
> [email protected] dev
> next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info - Loaded env from /home/arcanist/Documents/Coding/test/my-t3-app/.env
Info detected host target triple "x86_64-unknown-linux-gnu"
INFO | Android emulator version 31.3.13.0 (build_id 9189900) (CL:N/A)
emulator: INFO: Found systemPath /home/arcanist/Android/Sdk/system-images/android-33/google_apis/x86_64/
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
INFO | Info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. ((null):0, (null))
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
event - compiled client and server successfully in 976 ms (275 modules)
INFO | added library /home/arcanist/Android/Sdk/emulator/qemu/linux-x86_64/lib64/vulkan/libvulkan.so
INFO | configAndStartRenderer: setting vsync to 60 hzms
INFO | Sending adb public key [QAAAAJPdAFVlN3r1mYAb3jvfX4vM2dJ8pVcz4WqDd9wqbvHr/Dxc4vs5vJKwd6zntF9IokPnDDEhTwDmKI+eGdubrw9CN+dmdQ0nj25uUhBvUFaIUqew5dMgg0Ys9eSKOsPVHPBV2/FNmtmyOTNmKuKiwx0PW363ezolzjwXSBF1nwPDXShkzhvGGJjWOf6XlXRBvQOkaskH82aWKlmA1U/ovFvdAw8mdtdO5QGSlc/eIooYKynu8yEzrBbYnM8+sB1d0tAjPD2nI4NNWuWxq//jC7wmZq/KUbEtAvt5g3UpGRBEVNKZqzbGm51HYCZCOD2wVL1DDqybCk2PYZnfIqeW6uaUFtyxjYp2zS6qSY82ZAdf+JbPHbB12brdFqu/Y08AuPh1AHcaOOz6DQ7rDzZWE1Rvgt93fN4G7IHa2ejKoURpDXrac84RzycRORC1XQ6Vld3wZka8r+/eGMaI5uWsCRFyiOR6z6TpOCQnymRk9KVB46PtIcEYa9Lbo9DgcU7gIIDuX8IULBrS6tVn4F7aJtDxNgBx6fFKgYtnb9izjTV7b0tzmiX0t0aKBts0Myy+mPu0mmNulHP8dzqKtpUHkDldC0gNPzqw0iLOcfEJ0eoGt3esPW7GT1mUnXZP9EXHvT7FxvMvAjuN5PwAs1KIvkEYrfJX947zSguXCXd8sfUHbrYtnQEAAQA= arcanist@framework]
INFO | injectedQemuChannel!
INFO | Informing listeners of injection.
INFO | Rootcanal has been activated.
WARNING | *** No gRPC protection active, consider launching with the -grpc-use-jwt flag.***
INFO | Started GRPC server at 127.0.0.1:8554, security: Local, auth: none
INFO | Advertising in: /run/user/1000/avd/running/pid_38965.ini
INFO | setDisplayConfigs w 1440 h 3120 dpiX 560 dpiY 560
INFO | Info: Sandboxing disabled by user. ((null):0, (null))
Additional context
Confirmed by another user in Discord.
I was able to get the app to launch on my actual Android device using the option to connect via WiFi in Android Studio, but there's no webview:
get same issue with https://github.com/Ludea/tauri-mobile
started server on 0.0.0.0:3000, url: http://localhost:3000/ Did you configure next.js for mobile? That might be the reason of the blank screen.
Now for the emulator problem I need more information. Can you try running from Android Studio with tauri android dev --open
?
Did you configure next.js for mobile?
I thought I did, but I realize I didn't do it correctly so I corrected everything on my end.
I still can't seem to launch the app inside the emulator even with tauri android dev --open
.
tauri android dev --open
and it only shows a blank Android device without my app installed.
If I open the generated Android app directory with Android Studio, I'm able to build it and upload it to my actual phone, but it just shows a blank app without the WebView. Even after making the suggested changes to to the Next.js config, I only have the app title showing up on the screen.
I'm able to access my app by visiting http://192.168.1.13:3000
in the Chrome browser inside the emulator:
Thanks to ChatGPT for explaining this to me. I changed the "Active Build Variant" to x86_64 (it was set to arm previously) and now I have the app launching in the emulator :partying_face:
If this is something that can be documented or set by default, that would be great. Otherwise feel free to close this issue. (I would also appreciate advice on why the app is not displaying in the WebView...)
I think the issue is that the WebView is not being added to the Android app. I opened up the generated directory in Android Studio and edited the Kotlin files to create a WebView and load the site at my local IP address. While that does work, I'm not able to use anything else from Tauri with this approach and I also wouldn't know how to make it load the correct URL in production.
Can anyone help?
I ran into the same problem.
Environment
› OS: macOS Ventura 13.0.1 (Intel Core i7, x86_64) › Node.js: v14.16.0 › npm: 8.19.3 › pnpm: Not installed! › yarn: Not installed! › rustup: 1.25.1 › rustc: 1.64.0 › cargo: 1.64.0
Logs when built in the normal way
$ npx tauri android dev
✔ What external IP should we use for your development server? · 192.168.1.2
Running BeforeDevCommand (`npm run dev`)
> [email protected] dev /Users/user/tauri-mobile-sample
> next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
event - compiled client and server successfully in 409 ms (165 modules)
Info detected host target triple "x86_64-apple-darwin"
INFO | Android emulator version 31.2.10.0 (build_id 8420304) (CL:N/A)
WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
INFO | configAndStartRenderer: setting vsync to 60 hz
WARNING | cannot add library /Users/user/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
INFO | Sending adb public key [xxxxx]
INFO | added library /Users/user/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
INFO | Rootcanal has been activated.
INFO | Started GRPC server at 127.0.0.1:8554, security: Local
INFO | Advertising in: /Users/suser/Library/Caches/TemporaryItems/avd/running/pid_38446.ini
In my environment, I was able to display the WebView of the application executed in the emulator by following the steps below.
$ npm run tauri android build
$ npm run tauri android dev -- --open
However, I don't think the above is a legitimate method. To me it looks like for some reason the tauri code is not building correctly.
You can check for console errors opening chrome://inspect
in your desktop to open the inspector. That will help us see why the webview is blank.
@arcanistzed Could you tell me what I can do to change the "Active Build Variant" to x86_64? 🙏
@arcanistzed Could you tell me what I can do to change the "Active Build Variant" to x86_64? 🙏
I changed it in Android Studio. Once you open the app as a project, there's a button on the bottom left that says Build Variants. If you open that panel and click on where it shows arm64 or whatever your current variant is, then you can change it which will automatically rebuild your project.
It seems like the issue is that the correct URL is not being set in src-tauri/gen/android/app/app/src/main/java/booking/app/MainActivity.kt
I did reproduce this once when I changed my package name to app
in Cargo.toml, then I opened Android Studio and it disappeared. Do you have more information @arcanistzed ?
I have the same issue running apps using vite from from fedora. After launching the emulator, the app does not start. In the console, there is no indication that it is even trying to start the dev server or compile rust.
INFO | Started GRPC server at 127.0.0.1:8554, security: Local, auth: none
INFO | Advertising in: /run/user/1000/avd/running/pid_86858.ini
INFO | Setting display: 0 configuration to: 1080x1920, dpi: 420x420
INFO | Boot completed in 15435 ms
INFO | Increasing screen off timeout, logcat buffer size to 2M.
INFO | Revoking microphone permissions for Google App
Running from android studio, I get the same blank app mentioned above.
Further, when I try to build for android, it compiles, but hangs with "waiting" when gradle should take over.
Finished release [optimized] target(s) in 9.82s
Info symlinking lib "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" in jniLibs dir "/home/stuart/motius-projects/discovery/vite-2/src-tauri/gen/android/vite2/app/src/main/jniLibs/x86_64"
Info "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" requires shared lib "libandroid.so"
Info "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" requires shared lib "libdl.so"
Info "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" requires shared lib "liblog.so"
Info "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" requires shared lib "libm.so"
Info "/home/stuart/motius-projects/discovery/vite-2/src-tauri/target/x86_64-linux-android/release/libvite2.so" requires shared lib "libc.so"
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 4 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
<-------------> 0% WAITING
> IDLE
> IDLE
> IDLE
> IDLE
From windows or mac with the same code, I can both build and run the dev server.
From fedora, I can run dev, and build apps using only cargo (e.g. vanilla js or sycamore)
Any update on this thread ? Kinda stuck now 'cause of this...
Could you guys try again with latest CLI and see if it is fixed? also checkout https://tauri.app/blog/2023/03/01/create-tauri-app-version-3-released#tauri-20-alpha--mobile-support to bootstrap a project using create-tauri-app
Works well 💚 macOS M1 Ventura 13.3.1
cargo install create-tauri-app
cargo create-tauri-app --alpha
cd tauri-app
cargo tauri android init
cargo tauri android dev