Issue
This is the output of adb devices inside a docker container (a windows server image - also the host is win 10)
PS C:\> adb devices
List of devices attached
PS C:\>
I need to create CI for a Xamarin project, all is done except the part where I need to install the app on the phone via adb....until now I found no solution to use adb from inside a win docker contaienr (for linux there is the option to --privileged -v /dev/bus/usb:/dev/bus/usb, but switching to Linux is not an option( due to company decisions))
Solution
ADB can connect to the device over WiFi and from a networking aspect Docker shouldn't cause any problems for this as long as the network of the Docker Host machine can send traffic to the network of the Android device (if they are the same network, then the answer is definitely yes).
First make sure that the Docker Host machine can reach your device over the WiFi network. A test like ping
ing the IP of your Android device from the Docker Host machine would work. After that, initiate the ADB over WiFi using the ADB on your Docker Host machine (not the one in your container).
adb tcpip 5555
Once that is done, open a terminal in the container and connect to the Android device using the ADB inside the container.
adb connect <ip-address-of-android-device>
adb devices
Usually, when a new connection is established from an "un-trusted" machine, the device requests the user to confirm the connection and so "trust" the machine. An adbkey
is created under %userProfile%/.android
on the machine which the device uses to establish a trust every time the connection is made after the first time it happens so that the user doesn't need to confirm the connection every time. Copy or volume bind the adbkey
into the <container_userProfile_directory>/.android
so device doesn't request from the user to confirm the connection every time.
Answered By - ahasbini
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.