developing android apps on gitpod
this project is intended to demonstrate how to easily program android apps on gitpod. it is based on this guide and this flutter template. this image already enables you to program for flutter web – in this guide however i want to focus on programming on a real device.
requirements
- gitpod (or other cloud ide)
- android phone (android 11+)
- ngrok (or other tunneling software)
- wi-fi connection between the current device (laptop) and the phone
step 1 – enable web debugging
references: gadgethacks – picture source / gitconnected
on your android 11+ phone, enable developer settings by tapping the build number multiple times. after the developer settings are unlocked, open them up and enable “wireless debugging”. once this is enabled, click on the text next to the toggle to get to the details of this setting.
write down the displayed ip and port – this is the connection for the main adb connection.
click on “pair device with pairing code” below – you will see a pairing code, the same ip address and a different port. write these down as well and keep this window open. this is the connection only for pairing.
step 2 – tunnel adb via ngrok
download ngrok. open a terminal on your computer, that must be in the same wifi network like the phone. you can verify this by pinging the phone ip address like ping 192.168.178.33
– if the ping succeeds, your network settings are correct.
run ngrok to tunnel the pairing connection first, for example
ngrok tcp 192.168.178.33:42739
. ngrok will provide you with an external domain and port, like 0.tcp.ngrok.io:13840
.
open your android code in your cloud ide with adb installed – like this example. use the command line terminal in the ide to pair the ide with the device like adb pair 0.tcp.ngrok.io:13840
. enter the pairing code and wait until the connection is confirmed.
terminate the ngrok tunnel for the pairing connection (ctrl + c in the local terminal). now create a new tunnel for the main adb connection, like ngrok tcp 192.168.178.33:37829
which will provide you with a new domain and port like 6.tcp.ngrok.io:16514
.
now connect to the main adb connection via adb connect 6.tcp.ngrok.io:16514
– this requires the previous pairing step to succeed. the connection should establish successfully.
step 3 – run the app
once the connection is established, you can use your phone in combination with the ide to work on apps as usual.
in the example mentioned above, you can list all connected devices via flutter devices
. build and push a development build to the device via flutter run
. this will compile the code, pushes it to the phone via the internet and launches it on the phone.
Comments are closed.