Skip to content

Instantly share code, notes, and snippets.

@jramiresbrito
Last active November 4, 2024 17:37
Show Gist options
  • Save jramiresbrito/846b9bebc560668eb2e7a97fb1cfc1ef to your computer and use it in GitHub Desktop.
Save jramiresbrito/846b9bebc560668eb2e7a97fb1cfc1ef to your computer and use it in GitHub Desktop.
Connect Android Devices to WSL2 with WIFI or USB

Pre-requisites

  • Your phone must have the developer mode unlocked
  • You must unlock the USB debug

1 - Download the SDK

The last SDK is available in https://dl.google.com/android/repository/platform-tools-latest-windows.zip

2 - Extract to any folder

Please do a favor to yourself and dont extract to root of your C drive. Using something like documents/code is enough

3 - Open the PowerShell and navigate to extracted folder, then run the server

As you didn't added the abd in the PATH, you must run the command with relative patch like:

./adb start-server

If everything is ok, it will prompt

* daemon not running; starting now at tcp:5037
* daemon started successfully

4 - Connect using a TCP connection

./adb tcpip 5555

this will prompt a request in your Phone. Just accept it.

5 - Connect adb from WSL2

In your WSL Linux, run the command:

adb connect host:5555 # or the port u've selected in step 4

to find your phone ip:

  • Open your phone wifi-settings
  • Click on Advanced
  • You will see your ip. It will be something like: 192.168.x.y

6 - Check you've successfully connected

adb devices

List of devices attached
192.168.0.15:5555       device

To stop the adb server just run

./adb kill-server
@velrino
Copy link

velrino commented Oct 24, 2024

Thank you!

Works here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment