7

Mac 上连接 Android 传输文件与配置 SDK platform tools 环境

 2 years ago
source link: https://blog.ichr.me/post/configurate-connection-with-android-on-mac/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Mac 上连接 Android 传输文件与配置 SDK platform tools 环境

转眼间已经大半年没有动过 Windows 了,自从下定决心将所有习惯全部转到 Mac 上后,双系统中的那一半就径直打入冷宫(?)。又当最近才发现 Open GApps 正式推出了 Android 10 的刷入包,半年前刷 GSI 发现没有谷歌套件退回 Android 9 的我决定再试一次。可是当数据线连接电脑和手机的时候,发现事情不对,有些设置还需要单独配置。

在 Windows 上连接 Android 手机传输文件十分简单:数据线连接 - 手机上打开文件传输模式(默认为仅充电),此时手机就像一个 U 盘,可以直接对 SD 卡的文件进行操作。但 Mac 不行,即便你按照上面的操作来一遍,Finder 还是无动于衷。不要怀疑你的数据线坏了,只是 Mac 不兼容而已,需要下载 Android 官方为 Mac 提供的 FileTransfer 工具。

前往 FileTransfer 官方页面 下载传输工具,常规安装,你甚至不需要打开,当你再次走一遍上述连接 Windows 文件传输的步骤后,FileTransfer 监测到连接会自动弹出,这样就可以在像使用 Finder 一样对手机 SD 卡的数据进行操作了。

20200208115006.jpg

SDK platform-tools 环境

玩机的朋友应该对 ADB/Fastboot 命令都不陌生,这些命令都是在 Android 官方提供的 SDK platform tools 工具箱里的。

安装也和 Windows 颇为类似。前往 Android developer - Android Studio - SDK platform tools - #download 下载 Mac 版本的,然后将下载的压缩包解压到任意目录。

解压后,还需要配置环境变量才能在终端中使用。定位到用户家目录,然后编辑 .bash_profile

# 定位到用户「家目录」
cd ~

# 编辑文件 .bash_profile
# 如果提示错误,可能是还未创建该文件,使用 touch .bash_profile 创建即可
vim .bash_profile
#  如果不会使用 vim 编辑器,也可以使用文本编辑器
open -e .bash_profile

# 在该文件追加 ADB 环境变量
export PATH=${PATH}:/Users/user_name/path/to/platform-tools 

# 使用命令使其立即生效(否则重启后生效)
source ~/.bash_profile

配置完成后,可以使用 adb version 检查是否生效,如果显示了版本号,就表示配置成功了。

20200208114947.jpg


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK