Android 에뮬레이터에서 Android Debug Bridge (adb) 사용 방법?
이 짧은 글에서는 Android Debug Bridge (adb) 명령어로 복잡한 작업을 몇 초 만에 처리하는 방법을 안내합니다.
1. Android Debug Bridge (adb)란?
Android Debug Bridge는 Android 개발자가 Android 에뮬레이터와 통신하고 여러 명령을 실행할 수 있게 해 주는 강력한 디버깅 도구입니다.
이 도구를 사용하면 다음과 같이 복잡하고 실수하기 쉬운 작업을 처리할 수 있습니다:
- HTTP 프록시 설정 변경 / 되돌리기
- Wi-Fi 네트워크 켜기/끄기
- 인증서 설치 및 신뢰
- 실행 중인 모든 앱 종료
- 그 밖에도 다양한 작업
명령줄로 많은 작업을 수행할 수 있으므로, 개발자는 앱의 UI/UX에 더 많은 시간을 쏟을 수 있습니다.
자세한 내용은 다음 링크에서 확인할 수 있습니다: https://developer.android.com/studio/command-line/adb
2. 설치
adb 명령어가 아직 설치되어 있지 않다면, 다음 안내에 따라 직접 설치할 수 있습니다:
1/ Homebrew 설치
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2/ adb 명령어 설치
$ brew cask install android-platform-tools
자세한 내용은 다음 링크에서 확인할 수 있습니다: https://stackoverflow.com/questions/31374085/installing-adb-on-macos
3. 자주 쓰는 작업
아래의 모든 작업에는 root 권한이 적용된 Android 에뮬레이터가 필요합니다.
Android 에뮬레이터 root 권한 얻기
Android 에뮬레이터가 Play Store 버전이 아니라 Google APIs 버전인지 확인하세요.

- Android Studio에서 Android 에뮬레이터를 엽니다
- 다음 명령어를 실행합니다
$ adb root
- 기기가 다시 시작될 때까지 몇 분 정도 기다립니다.
HTTP 프록시 설정 변경
- Android 에뮬레이터의 HTTP 프록시를 IP 127.0.0.1, 포트 9090으로 변경합니다
adb shell settings put global http_proxy 127.0.0.1:9090
HTTP 프록시 되돌리기
- 명령줄로 HTTP 프록시 설정을 변경했으므로, 더 이상 필요하지 않을 때는 반드시 되돌려야 합니다. 그렇지 않으면 Android 에뮬레이터가 인터넷에 접속하지 못할 수 있습니다.
adb shell settings put global http_proxy :0
자체 서명 인증서 설치 및 신뢰
- Android 에뮬레이터에 자체 서명 인증서를 설치하고 신뢰하도록 설정하는 것은 번거롭습니다. 특히 Android 11 이상에서는 시스템에서 인증서를 신뢰하도록 추가 단계가 필요합니다.
다음 명령어를 사용하면 자동으로 처리할 수 있습니다:
# 1. Prepare your certificate
$ subjectHash=`openssl x509 -inform PEM -subject_hash_old -in my-certificate.pem | head -n 1`
$ openssl x509 -in my-certificate.pem -inform PEM -outform DER -out $subjectHash.0
# 2. Copy to Android Emulators
$ adb push ./$subjectHash.0 /data/misc/user/0/cacerts-added/$subjectHash.0
$ adb shell "su 0 chmod 644 /data/misc/user/0/cacerts-added/$subjectHash.0"
# 3. Restart your android emulator to take effect!
다음 경로에서 인증서가 올바르게 설치되고 신뢰되었는지 확인할 수 있습니다:
- 설정 앱 -> Security -> Encryption & Credentials -> Trusted Certificate -> User 탭
Wi-Fi 네트워크 켜기
$ adb shell svc wifi enable
실행 중인 모든 앱 종료
- 스크립트 준비: closeall.sh
APPS=$(adb shell dumpsys window a | grep "/" | cut -d "{" -f2 | cut -d "/" -f1 | cut -d " " -f2)
for APP in $APPS ; do
echo "Closing: $APP"
adb shell am force-stop $APP
done
- 스크립트 실행
./closeall.sh
4. Proxyman과 함께 쓰는 ADB
Proxyman 2.10.0부터는 Android 에뮬레이터용 Automatic Script가 도입되어, 복잡한 작업을 클릭 한 번으로 수행할 수 있습니다.
다음 작업이 포함됩니다:
- HTTP 프록시를 Proxyman으로 변경
- 필요한 경우 HTTP 프록시 되돌리기
- Proxyman CA 인증서를 자동으로 다운로드하고 Android 에뮬레이터에 설치 및 신뢰
다음 경로에서 사용할 수 있습니다: Certificate 메뉴 -> Install Certificate on Android -> Emulator

자세한 내용은 다음 링크에서 확인할 수 있습니다: https://proxyman.com/docs/debug-devices/android-device/automatic-script-for-android-emulator
현재 권장 방법
인증서를 직접 복사하기 전에 Proxyman의 Automatic Script를 사용하세요. 최신 버전에서는 에뮬레이터의 프록시를 설정하고 Proxyman 인증서를 시스템 인증서 저장소에 설치할 수 있습니다. 먼저 adb에서 에뮬레이터가 보이는지 확인하고, 지원되는 Google APIs 이미지를 사용하세요. 작업이 끝나면 Revert All Changes를 선택하세요. 그래야 Proxyman을 종료한 뒤에도 에뮬레이터가 인터넷에 연결됩니다.
Proxyman은 개발자가 iOS 기기, iOS 시뮬레이터, Android 기기에서 HTTPS 트래픽을 캡처할 수 있게 해 주는 고성능 macOS 앱입니다.
다음에서 받을 수 있습니다: https://proxyman.com

