Skip to content

Instantly share code, notes, and snippets.

@hochun836
Last active August 30, 2023 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hochun836/2bcbf33015f06d7ee6c44f4696d1b87e to your computer and use it in GitHub Desktop.
Save hochun836/2bcbf33015f06d7ee6c44f4696d1b87e to your computer and use it in GitHub Desktop.
# base
# tools
android sdk command-line tools
android sdk build tools
android sdk platform tools
=> ref: https://developer.android.com/tools
NOTE: platform-tools
android sdk 'platform-tools' is a component for the android sdk
it includes tools that interface with the android platform, primarily 'adb' and 'fastboot'
=> ref: https://developer.android.com/tools/releases/platform-tools
NOTE: adb (android debug bridge)
adb is a client-server program that includes three components
- a client
- the client runs on your development machine
- the client sends commands
- a daemon (adbd)
- the daemon runs as a background process on each device
- the daemon runs commands on a device
- a server, which manages communication between the client and the daemon
- the server runs as a background process on your development machine
- the server manages communication between the client and the daemon
=> ref: https://developer.android.com/tools/adb
NOTE: debug over an adb (android debug bridge) connection
step1. set up a device for development
step2. connect to your device using USB or WIFI
if run 'adb devices' doesn't show your device, then go through the followings
step3. make sure OEM (original equipment manufacturer) USB driver has been installed // Windows needs, but macOS doesn't
step4. make sure your device has been unlocked
step5. make sure your device has been confirmed on any dialog
step6. restart the adb server and recheck
adb kill-server
adb devices
=> ref: https://developer.android.com/studio/run/device
=> ref: https://developer.android.com/studio/run/oem-usb
for VIVO
=> ref: https://vivodriver.com/vivo-usb-driver-v1-1-0
NOTE: Google USB Driver
the Google USB Driver is required to perform adb debugging on Windows with Google devices
Windows drivers for all other devices are provided by the respective hardware manufacturer
=> ref: https://developer.android.com/studio/run/win-usb
# android sdk platform
each sdk platform version includes the following packages
- the android sdk platform package
- it is required to compile your app for that version
- several system image packages
- at least one of these is required to run that version on the android emulator
- the sources for android package
=> ref: https://developer.android.com/tools/releases/platforms
NOTE:
the revision numbers listed below are for the 'android sdk platform package' only
the 'system images' may receive separate updates, usually to resolve bugs with the emulator
there are no release notes for the system images, but you should always keep them up to date
Android 14 (API level 34)
Android 13 (API level 33)
Android 12 (API levels 31, 32)
Android 11 (API level 30)
Android 10 (API level 29)
Android 9 (API level 28)
Android 8.1 (API level 27)
Android 8.0 (API level 26)
Android 7.1 (API level 25)
Android 7.0 (API level 24)
Android 6.0 (API level 23)
Android 5.1 (API level 22)
Android 5.0 (API level 21)
Android 4.4W (API level 20)
Android 4.4 (API level 19)
Android 4.3 (API level 18)
Android 4.2 (API level 17)
Android 4.1 (API level 16)
Android 4.0.3 (API level 15)
Android 4.0 (API level 14)
Android 3.2 (API level 13)
Android 3.1 (API level 12)
Android 3.0 (API level 11)
Android 2.3.3 (API level 10)
Android 2.3 (API level 9)
...
# adb
adb --help
adb help
adb version
adb connect <ip> // connect to a device via tcp/ip, default port: 5555
adb connect <ip>:<port>
adb connect 127.0.0.1:58526
adb disconnect // disconnected everything
adb disconnect <ip> // default port: 5555
adb disconnect <ip>:<port>
adb disconnect 127.0.0.1:58526
adb devices // list the attached devices
adb devices -l // l: long output
adb start-server
adb kill-server
adb -L tcp:5037 fork-server server --reply-fd 632 // run a server
adb push <local-file-path> <remote-directory-path> // push files
adb push <local-file-path> <local-file-path> <remote-directory-path>
adb push C:\a.txt C:\b.txt /sdcard
adb pull <remote-file-path> <local-directory-path> // pull files
adb pull <remote-file-path> <remote-file-path> <local-directory-path>
adb pull /sdcard/a.txt /sdcard/b.txt C:\
adb shell // run remote shell
adb shell <command> // run remote shell command
adb shell dumpsys window windows
adb shell dumpsys window windows | findstr mFocusedApp // get the current opened app in windows
adb shell dumpsys window windows | grep mFocusedApp // get the current opened app in macos
adb shell am start -W <package>/<activity> // am: activity manager, start: start activity, W: wait for launch to complete
adb shell am start -W com.microsoft.emmx/com.microsoft.ruby.Main
adb shell pm list packages // pm: package manager
adb shell pm list packages -f // f: associated file
adb shell pm list features
adb shell dumpsys media.camera
adb shell screencap -h
adb shell screencap // the result is printed to stdout
adb shell screencap <file-path> // the result is saved to the specified path
adb shell screencap -p <file-path> // p: png
adb shell screencap -p /sdcard/screen.png
adb shell getprop // list all props
adb shell getprop <prop> // list the specified prop
adb shell getprop ro.build.version.sdk
adb -s <serial> shell // run remote shell, using device with the given serial
adb -s <serial> shell <command> // run remote shell command, using device with the given serial
adb logcat --help
adb logcat // show device log
adb install <apk-path>
adb uninstall <package>
NOTE:
adb -s <serial> shell // work
adb shell -s <serial> // not work
NOTE: activity manager
adb shell
$ am -h
$ am help
$ am start <intent>
$ am start-activity <intent>
$ am start-service <intent>
$ exit
# [note] learn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment