Android debug bridge
Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:
- A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
- A daemon, which runs as a background process on each emulator or device instance.
You can find the adb tool in:
Adb command
ADB의 명령어 목록.
-
adb devices
: adb 서버가 인식한 휴대폰과 에뮬레이터 목록을 보여준다. 연결된 devices의 TCP/IP 포트 번호를 알아낼 때 도움이 된다. -
adb devices -l
:adb devices
명령의 긴 포맷 버전. -
adb install [-l][-r] file_spec
: app을 설치하거나 재설치할 때 사용한다.- -l : 다른 장치로 복사돼 넘어가는 것을 막는다.
- -r: 이미 존재하는 app 데이터를 지우지 않은 채 어플리케이션을 재설치 한다.
- file_spec: 설치할 app의 .apk 파일
adb uninstall [-k] package
: 패키지 이름을 가진 app을 제거하다.- -k : app의 데이터를 보존한다.
- package: 패키지의 전체 경로, .apk 확장자는 빼야 한다.
adb push local remote
: 개발자 컴퓨터에 있는 local이란 이름을 가진 파일을 타겟 시스템에 remote란 이름으로 복사한다.- e.g.
./adb push ~/Project/EduPiano/godot/EduPiano.apk /sdcard/Download/
adb pull remote local
: 타겟 시스템에 있는 remote라는 파일을 개발자 컴퓨터에 local이란 이름으로 복사한다. adb reboot
: 안드로이드 시스템을 리부팅 시킨다. adb kill-server
: adb 에 문제가 있을 경우, adb를 종료시킨다. adb start-server
: 종료된 adb를 실행 시킨다. Adb shell commands
ADB Shell은 간소한 유닉스 쉘 같아서 간단한 명령으로 타겟 시스템을 탐색하고 수정할 수 있다. 타겟 시스템의 쉘에 연결하고 #
프롬프트를 띄우는 방법은 아래와 같다.
아래는 쉘에서의 유용한 명령어 모음이다.
-
logcat
: 로그캣 보기. -
pm
: package manager의 약자. 패키지/permission/instrumentation/feature 목록, 패키지 설치/제거 등. -
am
: activity manager의 약자, 액티비티 시작, Intent 브로드캐스팅, Instrumentation 시작, profiling 시작 / 중지 등. -
service
: 안드로이드 서비스 목록 표시, 서비스에 명령 전달. -
monkey
: 애플리케이션에 랜덤 이벤트 발생시킴. 사용자 이벤트, 시스템 이벤트의 무작위 발행. -
cat /data/anr/traces.txt
: VM TRACES (쓰레드 덤프). -
cat /proc/binder/proc/[PID]
: 바인더 프로세스 상태. -
cat /proc/binder/xxx
: 바인더 관련 정보(xxx은 transaction, transaction_log, failed_transaction_log, stats 등). -
cat /data/system/packages.xml
: 설치된 패키지 세팅 정보. -
setprop
: system property 셋팅. -
getprop
: 셋팅된 system property 목록 출력. -
dumpsys [service]
: app/service 상태정보 덤프, 서비스별로 추가 파라미터 받을 수 있음. -
dumpstate
: device 상태정보 덤프. 상태정보를 추출하는 여러 명령어들의 조합으로 구성. -
dumpcrash
: 애플리케이션이 crach될 때의 상태정보 덤프. -
bugreport
: logcat + dumpsys + dumpstat.