问题
adb shell run-as /data/data/com.mypackagename
returns
adb command not found
though I see adb in the directory (/Users/me/Library/Android/sdk/platform-tools
)
回答1:
You just need to add this path to your bash profile and source it:
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
adb devices
回答2:
If you are in that directory, you can run it with a leading dot-slash, i.e. ./adb shell run-as /data/data/com.mypackagename
.
In general, you might want to add that directory to your PATH
environment variable.
回答3:
The first step, you should get android sdk directory path by open:
Android Studio -> Preferences -> Appearance & Behavior -> System Settings -> Android SDK
The path will be show here. example: /Users/thisismyaccount/Library/Android/sdk
Next, you open Terminal and type command as below:
echo 'export PATH=$PATH:/Users/*thisismyaccount*/Library/Android/sdk/platform-tools/' >> ~/.bash_profile
source ~/.bash_profile
adb devices
回答4:
If you are using Catalina:
echo 'export PATH=$PATH:~/Library/Android/sdk/platform-tools/' >> ~/.zshrc
source ~/.zshrc
adb devices
回答5:
For Xamarin Studio users, this is a copy/paste from the Xamarin forums
From Xamarin Studio, go to Tools, then select "Open Android SDK Command Prompt". This will open a terminal window and automatically navigate you to the Android SDK location. From there you can use the ADB command.
回答6:
As HuyTTQ said, first check your android SDK path.
Then export it:
export ADB="/Users/your_username/Library/Android/sdk/platform-tools/adb"
$ADB devices
this will only work temporarily for this opened terminal.
来源:https://stackoverflow.com/questions/27970352/how-do-i-run-adb-on-a-mac-terminal