Live Brilliant

ADB 사용하기 본문

개발은 핵찜이야/Android

ADB 사용하기

주인정 2012. 4. 17. 20:02
지금부터 ADB를 사용하는 방법에 대해 알아보도록하자.ADB(Android Debug Bridge) 안드로이드 개발을 위한 디버깅 툴이다.

SDK 를 설치할 때 (C:\Android\android-sdk_r05\tools;) 환경변수에 tools 까지 path 로 잡아준 적이 있다.

tools 안에 adb.exe 가 있다.


1. 설정 안드로이드 sdk설치시 PATH 를 잡아 주었다면 command 창에서 간단히 실행이 가능하다 1) 윈도우 시작 -> 실행 -> cmd 라고 치면 command 창이 나온다. C:\Documents and Settings\home> adb 라고 치면 아래 내용이 보여진다.
??-d
- directs command to the only connected USB device?returns an error if more than one USB device is present.
?-e
- directs command to the only running emulator.?returns an error if more than one emulator is running.?
-s <serial number>
- directs command to the USB device or emulator with?the given serial number
?-p <product name or path>
- simple product name like 'sooner', or?a relative/absolute path to a product?out directorylike 'out/target/product/sooner'.?If -p is not specified, the ANDROID_PRODUCT_OUT environment variable is used, which must be an absolute path.
?devices - list all connected devices

?device commands:
??adb push <local> <remote> - copy file/dir to device
?adb pull <remote> <local> - copy file/dir from device?
adb sync [ <directory> ] - copy host->device only if changed?(see 'adb help all')?
adb shell - run remote shell interactively
?adb shell <command> - run remote shell command
?adb emu <command> - run emulator console command
?adb logcat [ <filter-spec> ] - View device log
?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] <file> - push this package file to the device and install it
?('-l' means forward-lock the app)
?('-r' means reinstall the app, keeping its data)
?adb uninstall [-k] <package> - remove this app package from the device
?('-k' means keep the data and cache directories)?
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?

DATAOPTS:
??(no option) - don't touch the data partition
?-w - wipe the data partition?
-d - flash the data partition

?scripting:
??adb wait-for-device - block until device is online?
adb start-server - ensure that there is a server running
?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 root - restarts adb with root permissions

?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 /data partitions will be updated.?
- it is "system" or "data", only the corresponding partition is updated.

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

adb shell
?타겟 시스템의 쉘에 연결하고 # 프롬프트를 띄운다. 쉘은 간소한 유닉스 같아서 간단한 명령으로 타겟 시스템을 탐색하고 수정할 수 있다.?

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

?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란 이름으로 복사한다.?
adb pull remote local?
타겟 시스템에 있는 remote라는 파일을 개발자 컴퓨터에 local이란 복사한다.?

2) adb 실행시 에러
=> 안드로이드 에뮬레이터가 실행이 안되서 디바이스가 없다고 한다

=>adb devices 연결된 장치목록 확인 연결된 장치의 목록이 아무것도 없다.3) adb 실행하기


=> 에뮬레이터 실행후 adb devices 명령어를 치면 emulator-5554 device 가 연결되어 있는것을 확인할수 있다.

=> adb shell 명령어를 치면 쉘 프롬프트가 나타난다.

쉘명령어는 리눅스 명령어를 사용하면 된다.

이제 디버거 가 에뮬레이터와 다리 역할을 하면서 각종 메시지를

전달해 줄것이다.

그래서

ADB(Android Debug Bridge)^^

 

'개발은 핵찜이야 > Android' 카테고리의 다른 글

sqlite 툴 사용하기  (0) 2012.04.18
안드로이드 한글입력기 설치 방법  (0) 2012.04.18
안드로이드 잡코드 모음  (0) 2012.04.18
Tabs 예제  (0) 2012.04.18
SQLite3 접속하기  (0) 2012.04.17
Comments