Skip to content

Instantly share code, notes, and snippets.

@arnav-kr
Last active February 6, 2025 16:01
Show Gist options
  • Select an option

  • Save arnav-kr/babe5090c6390e3030148bb42e68c05c to your computer and use it in GitHub Desktop.

Select an option

Save arnav-kr/babe5090c6390e3030148bb42e68c05c to your computer and use it in GitHub Desktop.
Run Flutter Apps in Project IDX on your real device

Run Flutter App from IDX on a real device

Using Wireless Debugging (Android 10+)

Note

Wireless Debugging requires you to be connected to a wifi network to work, else Wireless Debugging Settings might not open

so there are basically two steps pairing and connecting. we use ngrok for accessing ports publically

Pairing

  • Go to Developer Options>Wireless Debugging after connecting to a wifi device
  • Enable it, and click on Pair device with pairing code
  • note the <PORT> and <PAIRING_CODE>
  • now in termux expose that port using ngrok, note the url (tcp://<NGROK_URL>)
    ngrok tcp <PORT>
  • Now in IDX Terminal run adb pair <NGROK_URL> <PAIRING_CODE>
  • The device is paired

Tip

Disable adb authorization timeout in developer options, so that you don't need to re-pair it after 7 days

Connecting

After the device is paired, its trusted by the phone, and can connect it without pairing again

Whenever connecting,

  • Open Wireless Debugging, and note the <PORT> in IP address & Port
  • again expose that in ngrok and note the <NGROK_URL>
    ngrok tcp <PORT>
  • In IDX Terminal connect to phone
    adb connect <NGROK_URL>
  • Devices is connected
  • Run on device using flutter
    flutter run -d <NGROK_URL>

Using ADBD Daemon

Warning

This method is less secure (Anyone with the ngrok url can adb into your device without any extra step)

  • Enable USB Debugging, connect your device to PC
  • start the adbd daemon on any port, say 5555
    adb tcpip 5555
  • In your termux, expose that port using ngrok, note the <NGROK_URL>
    ngrok tcp 5555
  • connect to device in IDX
    adb connect <NGROK_URL>
  • Run app on device
    flutter -d <NGROK_URL>

Ngrok on termux

to install ngrok:

pkg update -y
pkg install git
git clone https://github.com/Yisus7u7/termux-ngrok

cd termux-ngrok
bash install.sh

then provide it the authtoken by

ngrok config add-authtoken <TOKEN_FROM_WEB_DASHBOARD>
@MobinX
Copy link
Copy Markdown

MobinX commented Sep 1, 2024

thanks thats great

@SudipThapa-Arc
Copy link
Copy Markdown

credit card credentials is asked to use tcp end points in ngrok, port is opened and then closed immediately

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