IT/안드로이드2012. 1. 27. 15:28

1.    ADB(Android Debug Bridge)의 개요    5

1.1.    ADB(Android Debug Bridge)란?    5

2.    ADB 실행방법    5

3.    ADB 명령어    6

3.1.    ADB(Android Debug Bridge 1.0.26 기준)    6

3.2.    ADB devices - list all connected devices    6

3.3.    device commands    7

3.4.    ADB shell - run remote shell interactively    7

3.5.    DATAOPTS    9

3.6.    scripting    10

 

1.    ADB(Android Debug Bridge)의 개요

 

1.1.    ADB(Android Debug Bridge)란?

     Android Debug Bridge (adb) is a versatile tool lets you manage the state of an emulator instance or Android-powered device.

[Android Debug Bridge(ADB)는 다목적 도구입니다 당신이 에뮬레이터 인스턴스 또는 안드로이드 구동 장치의 상태를 관리할 수 있는 다목적 도구이다.]

    애플리케이션의 .apk 파일을 에뮬레이터나 디바이스에 인스톨하거나 커맨드 명령을 통해서 에뮬레이터나 디바이스에 억세스할때 사용

    에뮬레이터나 디바이스에서 수행되는 소스를 표준 디버거와 연결하는 역할도 수행

 

2.    ADB 실행방법

1. [시작]->[실행]->cmd 입력 후 확인으로 cmd창을 켜자

2. android SDK 설치 폴더내 tools로 이동한다.

3. 이 위치에서 adb 명령어가 적용 된다.

 

안드로이드는 리눅스를 기반으로 하였기 때문에 adb(Android Debug Bridge) 의 모든 기능은 커맨드 명령어로 가능하다. 기기가 없을 때 개발시 에뮬레이터를 띄워 작업을 하게 되는데, 이 에뮬레이터와 인터페이스를 해 여러가지 작업을 할수 있도록 도와주는 것이 adb(Android Debug Bridge) 유틸이다. 이름에서 알수있듯이 안드로이드 장치를 조작할수 있는 다리 역할을 한다.

 

3.    ADB 명령어

3.1.    ADB(Android Debug Bridge 1.0.26 기준)

     -d    - directs command to the only connected USB device

유일하게 연결된 USB 장치에 명령을 지시

returns an error if more than one USB device is present.

현재 USB 장치가 1개 이상이 있다면 오류반환

    -e    - directs command to the only running emulator.

유일하게 실행중인 에뮬레이터에 명령을 지시

returns an error if more than one emulator is running.

현재 USB 장치가 1개 이상이 있다면 오류반환

     -s <serial number>    - directs command to the USB device or emulator with the given serial number.

시리얼 넘버가 주어진 에뮬레이터 또는 USB 장치에 명령을 지시

     -p <product name or path> - simple product name like 'sooner', or

a relative/absolute path to a product out directory like 'out/target/product/sooner'.

If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used, which must be an absolute path.

3.2.     ADB devices - list all connected devices

- 현재 연결되어 있는 장치(Device) 목록을 화면에 보여줌

- adb 서버가 인식한 휴대폰과 에뮬레이터 목록을 보여준다. 연결된 devices의 TCP/IP 포트 번호를 알아낼 때 도움이 된다. -s나 -e 옵션은 여러 개의 장치를 연결했을 때 특정한 디바이스를 지정할 때 사용

 

 

     connect <host>:<port> - connect to a device via TCP/IP

TCP/IP를 통해 장치에 연결

     disconnect <host>:<port> - disconnect from a TCP/IP device

TCP/IP 장치로부터 연결 해제

 

3.3.     device commands

     adb push <local> <remote> - copy file/dir to device

ex) db push C:\log.txt /sdcard/log.txt 로컬위치의 log.txt 파일을 장치의 /sdcard/log.txt로 복사

     adb pull <remote> [<local>] - copy file/dir from device

ex) adb pull /sdcard/log.txt C:\log.txt 장치의 /sdcard/log.txt 파일을 로컬위치의 log.txt로 복사

     adb sync [ <directory> ] - copy host->device only if changed

호스트에서 장치로 변경된것만 단방향 동기화

 

3.4.     ADB shell - run remote shell interactively

- 아래와 같이 안드로이드 장치(Device)에 쉘 형태로 접근하여 제어(타겟 시스템을 탐색하고 수정)할 수 있다. 안드로이드는 리눅스를 바탕으로 하고 있기 때문에, 기본적인 커맨드 명령(ls, cat, rm, ps 등의 명령)을 실행할 수 있는 특징을 가지고 있다. 이런 특징은 안드로이드에서 관리자 권한윽 획득하는 루팅(Rooting)작업을 진행할 수 있는 요소이기도 하다.

쉘 프롬프트를 이용하면 에뮬레이터/단말기 내의 파일을 조회 및 수정할 수 있습니다. 대부분의 리눅스 프롬프트 명령을 동일하게 사용할 수 있습니다.

 

두 개 이상의 에뮬레이터/단말기가 연결되어 있을 경우 -s 옵션을 사용하여 접속할 에뮬레이터/단말기를 지정해 주어야 합니다. -s 옵션 뒤에 접속할 에뮬레이터의 이름이나 단말기의 일련번호를 입력하면 됩니다.

 

     adb shell <command> - run remote shell command

     adb shell monkey - shell이라는 툴을 사용하여 프로그램의 스트레스 테스트를 수행합니다. monkey는 안드로이드에 스트레스 테스트 툴입니다.

     adb emu <command> - run emulator console command

     adb logcat [ <filter-spec> ] - View device log

로그캣 로그를 타겟 시스템에서 볼 수 있는 명령. 현재까지 축적한 모든 로그를 터미널에 출력하고 시스템이 실행중인 동안 발생하는 추가적인 로그도 계속 출력한다. 이 명령은 주로 맨 뒤에 &를 붙여서 실행하는데, 이 기호를 명령 뒤에 붙이면 유닉스에서처럼 '별도의 프로세스로 이 명령을 실행하라'는 뜻이 된다.

     adb logcat --help

logcat의 활용 방법을 확인 할 수 있습니다.

DDMS에 LogCat과 같은 기능이지만 때로는 더 빠르고 편리할 때도 있습니다.

     adb forward <local> <remote> - forward socket connections

 

forward specs are one of:

tcp:<port>

localabstract:<unix domain socket name>

localreserved:<unix domain socket name>

localfilesystem:<unix domain socket name>

dev:<character device name>

jdwp:<process pid> (remote only)

     adb jdwp - list PIDs of processes hosting a JDWP transport

     adb install [-l] [-r] [-s] <file> - push this package file to the device and install it

- 애플리케이션을 설치하거나 재설치할 때 사용한다.

('-l' means forward-lock the app)

- l 옵션을 사용하면 애플리케이션이 다른 장치로 복사돼 넘어가는 것을 막는다.

('-r' means reinstall the app, keeping its data)

- r 옵션을 사용하면 이미 존재하는 애플리케이션 데이터를 지우지 않은 채 애플리케이션을 재설치할 수 있다.

('-s' means install on SD card instead of internal storage)

<file> 은 *.apk 이다.

    adb uninstall <file>

안드로이드에 설치되 프로그램을 제거합니다.

Note: adb -s emulator-5554 install helloApp.apk와 같이 여러개의 장비가 연결되어 있는경우 모든 adb 명령에 -s [장치명]으로 장치를 명시해 주어야 합니다.

     adb uninstall [-k] <package> - remove this app package from the device

('-k' means keep the data and cache directories)

-> apk 확장자는 빼야한다.

     adb bugreport     - return all information from the device

that should be included in a bug report.

     adb help    - show this help message

     adb version    - show version num

 

3.5.    DATAOPTS

(no option)    - don't touch the data partition

     -w    - wipe the data partition

     -d    - flash the data partition

 

3.6.    scripting

     adb wait-for-device     - block until device is online

     adb start-server        - ensure that there is a server running

adb 명령을 처음 실행하면 adb 서버가 자동으로 실행이 됩니다. (adb start-server)

adb 서버가 실행되고 장시간 사용하면서 디버기 하다보면 속도가 느려기거나 재대로 작동하지 않는 경우가 발생합니다.

이럴때는 adb kill-server명령을 수행하여 서버를 내린후 다시 adb start-server로 서버를 실행하면 성능이 향상될 수 있습니다.

     adb kill-server     - kill the server if it is running

     adb get-state     - prints: offline | bootloader | device

: 기기의 상태를 알려줌 – 출력 : 오프라인 | 부트로더 | 디바이스

     adb get-serialno     - prints: <serial-number>

: 기기의 일련번호를 알려줌 - 출력 : <일련번호>

     adb status-window     - continuously print device status for a specified device

     adb remount     - remounts the /system partition on the device read-write

     adb reboot [bootloader|recovery]     - reboots the device, optionally into the bootloader or recovery program

     adb reboot-bootloader    - reboots the device into the bootloader

     adb root    - restarts the adbd daemon with root permissions

     adb usb    - restarts the adbd daemon listening on USB

     adb tcpip <port>    - restarts the adbd daemon listening on TCP on the specified port

networking:

adb ppp <tty> [parameters] - Run PPP over USB.

Note: you should not automatically start a PPP connection.

<tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1

[parameters] - Eg. defaultroute debug dump local notty usepeerdns

 

adb sync notes: adb sync [ <directory> ]

<localdir> can be interpreted in several ways:

- If <directory> is not specified, both /system and /data partitions will be updated.

- If it is "system" or "data", only the corresponding partition

is updated.

 

좀 더 많은 내용은 개발자 문서의 adb 항목 (http://developer.android.com/guide/developing/tools/adb.html)을 참고하세요



"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."
Posted by 프리스케이터