一、配置环境变量
- 首先找到 SDK 安装位置
- 可以通过 AndroidStudio -Tools - Android - SDKManager 找到位置
- 创建 .bash_ 文件
export PATH=${PATH}:/Users/xxxx/Application/android-sdk-mac_x86/tools:/Users/xxxx/Library/Android/sdk/platform-tools
+输入 source .bash_
来立即生效刚才的配置。
- 之后可以使用 adb 命令来验证。
- 如果没有出现 command not found 那么配置成功
二、权限问题
- 模拟器环境
localhost:~ xxx$ source .bash_
localhost:~ xxx$ adb shell
//如果此时输入一些命令,会出现没有权限的信息
generic_x86:/ $ls
ls: ./ueventd.rc: Permission denied
ls: ./ueventd.ranchu.rc: Permission denied
ls: ./ueventd.goldfish.rc: Permission denied
ls: ./service_contexts: Permission denied
ls: ./sepolicy: Permission denied
ls: ./selinux_version: Permission denied
ls: ./seapp_contexts: Permission denied
ls: ./init.zygote32.rc: Permission denied
ls: ./init.usb.rc: Permission denied
ls: ./init.usb.configfs.rc: Permission denied
ls: ./init.rc: Permission denied
ls: ./init.ranchu.rc: Permission denied
ls: ./init.goldfish.rc: Permission denied
ls: ./init.environ.rc: Permission denied
ls: ./init: Permission denied
ls: ./fstab.ranchu: Permission denied
ls: ./fstab.goldfish: Permission denied
ls: ./file_contexts.bin: Permission denied
ls: ./default.prop: Permission denied
acct charger d dev mnt proc root sdcard sys vendor
cache config data etc oem property_contexts sbin storage system
//通过 su root 来获取 root 权限,之后再执行命令,就可得到结果
1|generic_x86:/ $ su root
generic_x86:/ # ls
//输出
adb app-private dalvik-cache mediadrm ota_package system_ce
anr backup data misc property system_de
app benchmarktest drm misc_ce resource-cache tombstones
app-asec bootchart local misc_de security user
app-ephemeral bugreports lost+found nativetest ss user_de
app-lib cache media ota system