本文描述ADB在MAC上的配置过程,以及常用的Command(ADB装x指南).更科学的Android SDK使用。

前情提要

  1. 请确保本地有 Android SDK,如无 请参见 Gradle环境配置一文
  2. 确保 SDK 中有 platform-tools,以下是我的配置路径
1
2
3
4
5
6
 keyle@keyles-MacBook-Pro  ~/Library/Android/sdk/platform-tools  ls -a
. adb fastboot sqlite3
.. api hprof-conv systrace
.DS_Store dmtracedump package.xml
NOTICE.txt etc1tool source.properties

配置MAC环境

打开terminal,在~路径下输入下面命令

1
2
3
4
5
6
//此命令写文本
vim .bash_profile
//进入编辑模式 粘贴如下配置
export PATH=$PATH:~/Library/Android/sdk/platform-tools
//键入:wq 结束编辑,返回后键入如下代码 完成配置
source .bash_profile

关于ADB你不得不知道的8个命令 The Most Common ADB Commands You Must Know 译文

ADB对于Andorid实在是Debug的桥梁啊,它允许你使用你的电脑控制你的手机。这种情况下你想在桌面上给你的手机安装APP,你就该用ADB了。ADB可以干很多类似事儿,比如说装APP,懂点使用ADB命令的知识是非常有益的(利于装x),你可以不碰手机能干老多事儿了,在下文,我们例举了常见的可以在操作手机的ADB指令。
ADB stands for Android Debug Bridge, and it allows you to communicate with your Android device using your computer. For instance, if you wish to install an app on your device right from your desktop, you can do so using ADB. There is a lot more you can do with ADB than just installing an app. Having knowledge of some of the most used ADB commands is really beneficial, as it will let you perform a number of actions on your device without even touching it. Here, we have compiled some of the common commands that you can use with ADB to perform actions on your device.

  1. Reboot your Device 重启手机
1
adb reboot
  1. Reboot into Recovery 重启进入Recovery模式
1
adb reboot recovery
  1. Reboot into Bootloader Mode 重启进入Bootloader模式
1
adb reboot bootloader

这里我想提醒看本文的朋友,如果不懂Bootloader模式是什么就不要进去了,可能会把手机变成 “真.砖”.
Bootloader是嵌入式系统在加电后执行的第一段代码,在它完成CPU和相关硬件的初始化之后,再将操作系统映像或固化的嵌入式应用程序装在到内存中然后跳转到操作系统所在的空间,启动操作系统运行.-来自百度百科的一段介绍

  1. Reboot into Fastboot 重启进入Fastboot模式
1
adb reboot fastboot
  1. Send File to your Device 给手机发送文件
1
adb push Source Destination

上面的命令支持你发送文件到设备上去,你只需要将文件的源路径写在命令的Source参数上和你想发送的目标参数填写完毕。
The above command lets you send files to your device. You just need to specify the source location of the file in the source argument in the command and the destination where you want to send your file.

  1. Get File from your Device 从手机获取文件
1
adb pull FileLocation Destination 

此命令支持你从手机拉取数据,换句话说,从手机接收文件。只需要填写设备上的文件路径与电脑上的目录即可正常运行。
It will let you pull, or in other words, receive a file from your device. Just specify the file location on your device and the destination in the command, and it should do the job for you.

  1. Install an App on your Device 安装APK
1
adb install APKLocation 

这条命令支持你从电脑安装手机APP,你只需要填写APK的特殊路径,他就会安装你选中的APK.
What this command does is let you install an app on your device right from your computer. You just need to specify the APK location in the command, and it will install the selected app on your device.

  1. Remount the System 重装系统
1
adb remount

如果你想重新挂载你设备的系统分区,可以用上面提到的命令
In case you want to remount the entire system of your device, you can issue the command mentioned above.
adb remount命令主要是 重新挂载系统分区,使系统分区重新可写(读写权限)

Conclusion 结论 略..
These were the most common ADB commands you should know if you have an Android device and you often connect it to your computer. It will save you some time that you will otherwise spend doing tasks manually.

Just having knowledge of some of the commands given above would prove to be really beneficial to you in the future. As if you ever wish to reboot your device into a specific mode or just want to install an app right off your computer, you will be able to do so by just issuing a single line of command from the Command Prompt Window

演示

安装与卸载APK