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

feat(cli): enhance Android dev port forwarding, use host IP for android devices, closes #11137 #11185

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

lucasfernog
Copy link
Member

this changes the android dev port forwarding (that is actually handled by the android-studio-script command - triggered by our Gradle plugin) with some enhancements:

  • make the whole process more resilient by checking if the port was actually forwarded and rerunning the adb reverse command until it tells us the forward is ready
  • if the adb devices list is empty, retry a few times (waiting a few seconds) to tolerate devices being booted - slows down "raw builds" (Build Project Android Studio menu for instance) that shouldn't happen often anyway - if you're running android dev you're usually running the app on a device instead of simply testing builds

this changes the `android dev` port forwarding (that is actually handled by the `android-studio-script` command - triggered by our Gradle plugin) with some enhancements:

- make the whole process more resilient by checking if the port was actually forwarded and rerunning the `adb reverse` command until it tells us the forward is ready
- if the `adb devices` list is empty, retry a few times (waiting a few seconds) to tolerate devices being booted - slows down "raw builds" (Build Project Android Studio menu for instance) that shouldn't happen often anyway - if you're running `android dev` you're usually running the app on a device instead of simply testing builds
@lucasfernog lucasfernog requested a review from a team as a code owner October 1, 2024 02:53
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Package Changes Through 5e2dbba

There are 5 changes which include tauri with prerelease, tauri-cli with prerelease, @tauri-apps/cli with prerelease, tauri-bundler with prerelease, tauri-macos-sign with prerelease

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-macos-sign 0.1.1-rc.0 0.1.1-rc.1
tauri-bundler 2.0.1-rc.14 2.0.1-rc.15
tauri 2.0.0-rc.16 2.0.0-rc.17
@tauri-apps/cli 2.0.0-rc.17 2.0.0-rc.18
tauri-cli 2.0.0-rc.17 2.0.0-rc.18

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@lucasfernog
Copy link
Member Author

i'm only able to test this on the emulators - but the same should apply to physical devices

i'm not at home right now and do not have access to my Android device..

@amrbashir
Copy link
Member

amrbashir commented Oct 2, 2024

This still doesn't work on my physical android device. I didn't have any issue with emulators before this PR, only with physical device. I tried with a couple of android devices and the same error persists.

This is what I see on the app when opened:

error sending request for url
(http://localhost:1420/)

@lucasfernog
Copy link
Member Author

ok i'm stealing a phone right now

@lucasfernog lucasfernog changed the title feat(cli): enhance Android dev port forwarding, closes #11137 feat(cli): enhance Android dev port forwarding, use host IP for android devices, closes #11137 Oct 2, 2024
@lucasfernog
Copy link
Member Author

lucasfernog commented Oct 2, 2024

I gave up and we're now using the host IP when running on physical devices; the port forwarding isn't reliable and it doesn't even work if the device is connected via wi-fi (though the cause of the reported issue is still unclear to me)

@tweidinger
Copy link
Contributor

Android test failed, so won't merge right now. The auditors won't be super happy with this kind of change for the sake of DX but I will create a high prio issue to fix this after release. Should be doable to handle everything over adb tunneling.

@amrbashir
Copy link
Member

amrbashir commented Oct 2, 2024

Posting here for visibility, the issue seems to happen with vite projects (only?), vanilla template with tauri's cli built-in devServer works fine with adb reverse.

Even though not tested, I assume leptos, yew and trunk based templates work as well since tauri's built-in devServer is a stripped version of trunk.

@lucasfernog lucasfernog merged commit a08e6ff into dev Oct 2, 2024
16 of 17 checks passed
@lucasfernog lucasfernog deleted the feat/android-port-forwarding-enhance branch October 2, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants