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.localhost #6454

Closed
ptechen opened this issue Mar 15, 2023 · 10 comments
Closed

[bug] 无法连接到 tauri.localhost #6454

ptechen opened this issue Mar 15, 2023 · 10 comments
Labels
platform: Android status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@ptechen
Copy link

ptechen commented Mar 15, 2023

Describe the bug

After Android apk package is built and installed, the web page that displays: https://tauri.localhost/ cannot be loaded because: net::ERR_CONNECTION_REFUSED

Reproduction

No response

Expected behavior

No response

Platform and versions

Environment
  › OS: Mac OS 13.2.1 X64
  › Node.js: 19.6.0
  › npm: 9.4.0
  › pnpm: Not installed!
  › yarn: 1.22.19
  › rustup: 1.25.2
  › rustc: 1.70.0-nightly
  › cargo: 1.70.0-nightly
  › Rust toolchain: nightly-aarch64-apple-darwin 

Packages
WARNING: no lock files found, defaulting to npm
  › @tauri-apps/cli [NPM]: 2.0.0-alpha.2
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 2.0.0-alpha.3,
  › tauri-build [RUST]: 2.0.0-alpha.1,
  › tao [RUST]: 0.17.0,
  › wry [RUST]: 0.26.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://0.0.0.0:1420/
package.json not found

App directory structure
  ├─ css
  ├─ dist
  ├─ target
  ├─ components
  ├─ public
  ├─ src-tauri
  ├─ .vscode
  ├─ views
  ├─ .idea
  └─ src

Stack trace

No response

Additional context

No response

@ptechen ptechen added status: needs triage This issue needs to triage, applied to new issues type: bug labels Mar 15, 2023
@ptechen
Copy link
Author

ptechen commented Mar 15, 2023

Need a locally running service to run, I don't get it! Is it because the webview must have access to a website?

@amrbashir
Copy link
Member

amrbashir commented Mar 15, 2023

https://tauri.localhost is an internal scheme that is intercepted by the android app and served locally, no network calls are made but can you check if AndroidManifest.xml contains android.permission.INTERNET? if not try adding these two permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Is the apk installed a debu version or release version?

if all fails please make a minimal repro app so I can investigate further.

@nomorechokedboy
Copy link

If your Cargo.toml was set

[features]
default = ["custom-protocol"]

you should remove/comment it

@etrnal70
Copy link

etrnal70 commented Apr 3, 2023

Hello, i'm also having this problem. Basically i'm just running pnpm tauri android dev after creating a new project using cargo create-tauri-app --alpha. Is there anything i should do to fix this ?

I will gladly provide more information if needed as i'm stuck in this without any clue 🥲

@amrbashir
Copy link
Member

Yes please make a minimal repro and provide the output of tauri info

@etrnal70
Copy link

etrnal70 commented Apr 4, 2023

Thank you for your response.

Output of `cargo tauri info`
⚡ cargo tauri info

Environment
  › OS: Arch Linux Rolling Release X64
  › Node.js: 19.1.0
  › npm: 8.19.3
  › pnpm: 7.30.3
  › yarn: Not installed!
  › rustup: 1.25.2
  › rustc: 1.68.2
  › cargo: 1.68.2
  › Rust toolchain: stable-x86_64-unknown-linux-gnu

Packages
  › @tauri-apps/cli [NPM]: 2.0.0-alpha.5
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 2.0.0-alpha.4,
  › tauri-build [RUST]: 2.0.0-alpha.2,
  › tao [RUST]: 0.16.0,
  › wry [RUST]: 0.24.1,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../src
  › devPath: ../src

App directory structure
  ├─ src-tauri
  ├─ .vscode
  ├─ src
  └─ node_modules

Android log when running `cargo tauri android dev`
--------- beginning of main
04-04 08:35:25.565  6784  6784 I m.equnix.pos_rs: Late-enabling -Xcheck:jni
04-04 08:35:25.717  6784  6784 W ziparchive: Unable to open '/data/app/~~Ho9B39OO1HNdXMOGU51ZIA==/com.equnix.pos_rs-_05Om1NzivgXZWeoordhbw==/base.dm': No such file or directory
04-04 08:35:25.717  6784  6784 W ziparchive: Unable to open '/data/app/~~Ho9B39OO1HNdXMOGU51ZIA==/com.equnix.pos_rs-_05Om1NzivgXZWeoordhbw==/base.dm': No such file or directory
04-04 08:35:26.182  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
04-04 08:35:26.183  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
04-04 08:35:26.345  6784  6784 W ziparchive: Unable to open '/data/app/~~OJuQmEycLw_k-A151B7_Eg==/com.google.android.trichromelibrary_556311634-fWdCzIIPXKeIGKQCDerWuA==/base.dm': No such file or directory
04-04 08:35:26.345  6784  6784 W ziparchive: Unable to open '/data/app/~~OJuQmEycLw_k-A151B7_Eg==/com.google.android.trichromelibrary_556311634-fWdCzIIPXKeIGKQCDerWuA==/base.dm': No such file or directory
04-04 08:35:26.345  6784  6784 W m.equnix.pos_rs: Entry not found
04-04 08:35:26.393  6784  6784 I WebViewFactory: Loading com.google.android.webview version 111.0.5563.116 (code 556311634)
04-04 08:35:26.484  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/os/Trace;->isTagEnabled(J)Z (unsupported, reflection, allowed)
04-04 08:35:26.484  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/os/Trace;->traceBegin(JLjava/lang/String;)V (unsupported, reflection, allowed)
04-04 08:35:26.484  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/os/Trace;->traceEnd(J)V (unsupported, reflection, allowed)
04-04 08:35:26.484  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/os/Trace;->asyncTraceBegin(JLjava/lang/String;I)V (unsupported, reflection, allowed)
04-04 08:35:26.484  6784  6784 W m.equnix.pos_rs: Accessing hidden method Landroid/os/Trace;->asyncTraceEnd(JLjava/lang/String;I)V (unsupported, reflection, allowed)
04-04 08:35:26.490  6784  6784 I cr_WVCFactoryProvider: Loaded version=111.0.5563.116 minSdkVersion=29 isBundle=true multiprocess=true packageId=2
04-04 08:35:26.540  6784  6784 I cr_LibraryLoader: Successfully loaded native library
04-04 08:35:26.541  6784  6784 I cr_CachingUmaRecorder: Flushed 9 samples from 9 histograms.
04-04 08:35:26.828  6784  6950 W chromium: [WARNING:dns_config_service_android.cc(115)] Failed to read DnsConfig.
04-04 08:35:26.830  6784  6903 I RustStdoutStderr: [WARNING:dns_config_service_android.cc(115)] Failed to read DnsConfig.
04-04 08:35:26.984  6784  6784 I Choreographer: Skipped 88 frames!  The application may be doing too much work on its main thread.
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: QUALCOMM build                   : 3e33337ce3, I07ee46fc66
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Build Date                       : 10/08/21
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: OpenGL ES Shader Compiler Version: EV031.35.01.10
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Local Branch                     :
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Remote Branch                    :
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Remote Branch                    :
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Reconstruct Branch               :
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Build Config                     : S P 10.0.7 AArch64
04-04 08:35:27.033  6784  6886 I AdrenoGLES-0: Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
04-04 08:35:27.053  6784  6886 I AdrenoGLES-0: PFP: 0x016ee201, ME: 0x00000000
04-04 08:35:27.073  6784  6886 E OpenGLRenderer: Unable to match the desired swap behavior.
04-04 08:35:27.183  6784  6886 W Parcel  : Expecting binder but got null!
04-04 08:35:27.190  6784  6832 I OpenGLRenderer: Davey! duration=937ms; Flags=1, FrameTimelineVsyncId=216860480, IntendedVsync=184490622657432, Vsync=184491357835392, InputEventId=0, HandleInputStart=184491361614047, AnimationStart=184491361619203, PerformTraversalsStart=184491361620505, DrawStart=184491451289359, FrameDeadline=184490634324098, FrameInterval=184491361385037, FrameStartTime=8354295, SyncQueued=184491502599776, SyncStart=184491502776599, IssueDrawCommandsStart=184491503663526, SwapBuffers=184491557618943, FrameCompleted=184491559882328, DequeueBufferDuration=27656, QueueBufferDuration=258646, GpuCompleted=184491559882328, SwapBuffersCompleted=184491558407484, DisplayPresentTime=0, CommandSubmissionCompleted=184491557618943,
04-04 08:35:27.241  6784  6968 W m.equnix.pos_rs: Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (unsupported, reflection, allowed)
04-04 08:35:27.276  6784  6968 W cr_media: BLUETOOTH_CONNECT permission is missing.
04-04 08:35:27.276  6784  6968 W cr_media: registerBluetoothIntentsIfNeeded: Requires BLUETOOTH permission
04-04 08:35:27.280  6784  6784 I Choreographer: Skipped 32 frames!  The application may be doing too much work on its main thread.
04-04 08:35:27.305  6784  6903 I RustStdoutStderr: Failed to request http://127.0.0.1:1430/: error sending request for url (http://127.0.0.1:1430/): error trying to connect: tcp connect error: Connection refused (os error 111)

For the repro, i didn't change any code after creating the apps. The steps to create are below:

  1. cargo create-tauri-app --alpha
  2. Project name: my-project
  3. Frontend > TypeScript/JavaScript
  4. Package manager > pnpm
  5. UI Template > Vanilla
  6. UI Flavor > JavaScript
  7. Setup the project for mobile > yes
  8. pnpm install, pnpm tauri android init, cargo tauri android dev

lucasfernog added a commit that referenced this issue Apr 4, 2023
… (#6631)

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
fix(cli): use local ip addr for built-in server on mobile, closes #6454
@amrbashir
Copy link
Member

Fix will be available in the next CLI release.

@107295472
Copy link

If your Cargo.toml was set

[features]
default = ["custom-protocol"]

you should remove/comment it

It doesn’t work on the PC side either. If you remove this protocol, you can no longer package it.

@qingfengfenga
Copy link

@amrbashir This issue is reproduced on the PC side and may require regression testing

@weiraneve
Copy link

I have same bug when I build a android app debug target.

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
None yet
Development

No branches or pull requests

8 participants