**Adb는 일반적으로 다음 위치에 있습니다:** ```bash #Windows C:\Users\\AppData\Local\Android\sdk\platform-tools\adb.exe #MacOS /Users//Library/Android/sdk/platform-tools/adb ``` **정보 출처:** [**http://adbshell.com/**](http://adbshell.com) # 연결 ``` adb devices ``` 이 명령은 연결된 장치를 나열합니다. 만약 "_**unauthorized**_"가 나타나면, 이는 **모바일**의 잠금을 해제하고 **연결**을 수락해야 함을 의미합니다. 이는 장치에 포트 5555에서 adb 서버를 시작해야 함을 나타냅니다: ``` adb tcpip 5555 ``` 해당 IP와 포트에 연결하세요: ``` adb connect : ``` 가상 Android 소프트웨어(예: Genymotion)에서 다음과 같은 오류가 발생하면: ``` adb server version (41) doesn't match this client (36); killing... ``` ADB 서버에 다른 버전으로 연결하려고 하기 때문입니다. 소프트웨어가 사용하는 adb 바이너리를 찾아보세요 ( `C:\Program Files\Genymobile\Genymotion`로 가서 adb.exe를 검색하세요) ## 여러 장치 **여러 장치가 귀하의 머신에 연결되어 있는 경우** 어떤 장치에서 adb 명령을 실행할 것인지 **지정해야 합니다**. ```bash adb devices List of devices attached 10.10.10.247:42135 offline 127.0.0.1:5555 device ``` ```bash adb -s 127.0.0.1:5555 shell x86_64:/ # whoami root ``` ## 포트 터널링 안드로이드 장치에서 **adb** **포트**에 **로컬호스트**에서만 **접근할 수** 있지만 **SSH를 통해 접근할 수** 있는 경우, **포트 5555를 포워딩**하고 adb를 통해 연결할 수 있습니다: ```bash ssh -i ssh_key username@10.10.10.10 -L 5555:127.0.0.1:5555 -p 2222 adb connect 127.0.0.1:5555 ``` # 패킷 관리자 ## 설치/제거 ### adb install \[option] \ ```bash adb install test.apk adb install -l test.apk # forward lock application adb install -r test.apk # replace existing application adb install -t test.apk # allow test packages adb install -s test.apk # install application on sdcard adb install -d test.apk # allow version code downgrade adb install -p test.apk # partial application install ``` ### adb uninstall \[options] \ ```bash adb uninstall com.test.app adb uninstall -k com.test.app Keep the data and cache directories around after package removal. ``` ## 패키지 모든 패키지를 출력하며, 선택적으로 패키지 이름에 \ 텍스트가 포함된 패키지만 출력합니다. ### adb shell pm list packages \[options] \ ```bash adb shell pm list packages adb shell pm list packages -f #See their associated file. adb shell pm list packages -d #Filter to only show disabled packages. adb shell pm list packages -e #Filter to only show enabled packages. adb shell pm list packages -s #Filter to only show system packages. adb shell pm list packages -3 #Filter to only show third party packages. adb shell pm list packages -i #See the installer for the packages. adb shell pm list packages -u #Also include uninstalled packages. adb shell pm list packages --user #The user space to query. ``` ### adb shell pm path \ 주어진 APK의 경로를 출력합니다. ```bash adb shell pm path com.android.phone ``` ### adb shell pm clear \ 패키지와 관련된 모든 데이터를 삭제합니다. ```bash adb shell pm clear com.test.abc ``` # 파일 관리자 ### adb pull \ \[local] 지정된 파일을 에뮬레이터/장치에서 컴퓨터로 다운로드합니다. ```bash adb pull /sdcard/demo.mp4 ./ ``` ### adb push \ \ 지정된 파일을 컴퓨터에서 에뮬레이터/장치로 업로드합니다. ```bash adb push test.apk /sdcard ``` # Screencapture/Screenrecord ### adb shell screencap \ 디바이스 화면의 스크린샷을 찍습니다. ```bash adb shell screencap /sdcard/screen.png ``` ### adb shell screenrecord \[options] \ Android 4.4 (API 레벨 19) 이상에서 실행되는 장치의 화면을 녹화합니다. ```bash adb shell screenrecord /sdcard/demo.mp4 adb shell screenrecord --size adb shell screenrecord --bit-rate adb shell screenrecord --time-limit