Search code examples
androidandroid-studiorobotics

Is there a way to build and run an Android Studio app on a phone remotely?


I am developing an app for Android that controls a robot using the FTC SDK, and I need to be able to make small changes to motor values in the code and re-install it to test the new code. My problem is that I need to do this a lot of times, and the system of taking the phone out of the mount (which takes a while) and plugging it into my computer to upload, waiting for it to upload, turning off the power to the robot, plugging the phone back in to the robot, and turning the power back on has started slowing our progress down a lot. I was wondering if there was any way I could install the new code on the phone without taking it out of the mount.

Our phone is connected to a usb hub with a webcam and the hardware controller, so I was wondering if attaching a wireless usb transmitter to the hub and my computer would still let the phone show up on the android studio connections manager and let me install it.

So if anyone has done this before, or knows about any way to make this work, thank you for the help!


Solution

  • Yes. First make sure that the robot phone has developer mode and USB debug enabled.

    (Do this by going to settings -> software info and click on build number ten times, then go settings -> developer options and enable USB Debug)

    Then, go into the robot controller phone and under the three dots at the top right select program and manage. Connect your computer to the shown internet name and password.

    Next if you are on Windows plug in the phone and run the following code in command prompt,

    pushd "%userprofile%\AppData\Local\Android\sdk\platform-tools"
    
    adb disconnect
    
    adb tcpip 5555
    adb connect 192.168.49.1
    
    popd
    
    PAUSE 
    

    If you are on Mac plug in the device and run the following code in terminal,

    cd ~/Library/Android/sdk/platform-tools
    
    ./adb disconnect
    
    ./adb tcpip 5555
    ./adb connect 192.168.49.1:5555
    

    Finally, disconnect the phone, go back to android studio and happy wireless coding.