Remote debugging with Android emulator

前端 未结 8 1080
耶瑟儿~
耶瑟儿~ 2020-11-30 17:09

Is it possible to write the code/compile Android application on one machine and debug it remotely on the emulator launched on another? I\'m sick and tired of the emulator co

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 17:33

    When you run adb, it starts a server copy of itself if one isn't already running. You can start that copy yourself on the machine with the device and since sdk 4.3 you can give it the -a option to tell that server to listen for remote machines. Do that with the following command which doesn't exit:

    adb -a -P 5037 server nodaemon

    On the machine you want to use the device from, set ADB_SERVER_SOCKET to tcp:xxxx:5037 in an environment variable (or give the same value to each adb invocation with the -L option), where xxxx is the IP address or hostname of the machine with the devices, and 5037 matches the port you gave the in the command above.

    We use this to give access to about 100 emulators spread over 3 machines to a machine running end to end tests in parallel, and to developers wanting to share real devices remotely.

    You can forward ports to and from the emulator with adb forward and adb reverse, and they'll appear on the machine with the devices (not the machine you're running 'adb forward' from).

提交回复
热议问题