[RN-CheatSheet] Android adb 여러 디바이스 연결 설정

HYUNGU, KANG·2022년 8월 16일
0

React-Native-CheatSheet

목록 보기
7/18

안드로이드 디바이스를 여러대 연결하는 경우, 아래와 같은 adb 명령어 입력시 에러가 발생한다.
adb reverse tcp:8081 tcp:8081 -> adb: error: more than one device/emulator

이럴때는 특정 디바이스를 선택해서 명령어를 실행할 수 있다.
adb devices 명령어를 입력하면, 아래와 같이 디바이스 아이디가 나오는데

List of devicesattached
DEVICE-ID-1device
DEVICE-ID-2device

이 디바이스 ID 를 함께 입력해줄 수 있다.
adb -s DEVICE-ID-1 reverse tcp:8081 tcp:8081

귀찮으면 아래 쉘 스크립트를 만들어두고, package.json 에 꼽아두고 사용하자.

#!/bin/bash

devices=$(adb devices | awk '$2 == "device" {print $1}')

for device_id in $devices
do
  adb -s $device_id reverse tcp:8081 tcp:8081
done
  scripts: {
    "adb:reverse": "adb start-server && sh adb-reverse.sh"
  }
profile
JavaScript, TypeScript and React-Native

0개의 댓글