Mac端Android Studio报错:需安装19.1.0及以上Android构建工具
Hey there, I’ve dealt with this exact headache before setting up Cordova/Ionic with Android Studio on Mac—those generic "set environment variables" answers never cut it, right? Let’s walk through the concrete steps to fix this:
Step 1: Make sure Android Build Tools are actually installed
First, don’t assume they’re there just because you installed Android Studio. Let’s verify and install them:
- Open Android Studio, go to Preferences (top menu: Android Studio > Preferences on Mac)
- Navigate to Appearance & Behavior > System Settings > Android SDK
- Switch to the SDK Tools tab
- Check the box next to Android SDK Build-Tools—make sure you select a version 19.1.0 or higher (I recommend picking the latest stable release)
- Click Apply to install the tools if they’re missing
Step 2: Locate your Build Tools path
On Mac, the default path for Android SDK is usually:
~/Library/Android/sdk/build-tools/[YOUR_INSTALLED_VERSION]
For example, if you installed version 34.0.0, it would be:
~/Library/Android/sdk/build-tools/34.0.0
(Pro tip: You can confirm the exact version by checking the folder in Finder)
Step 3: Set up environment variables properly (no vague advice here)
This is where most generic answers fall short—let’s do this step-by-step:
- Open Terminal on your Mac
- If you use Zsh (Mac’s default shell since Catalina), run:
If you use Bash, run:open ~/.zshrcopen ~/.bash_profile - Add these two lines at the end of the file (replace
[YOUR_INSTALLED_VERSION]with your actual build tools version):export ANDROID_HOME=~/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/build-tools/[YOUR_INSTALLED_VERSION]:$ANDROID_HOME/platform-tools - Save the file and close the text editor
- Back in Terminal, run this to apply the changes immediately:
(Orsource ~/.zshrcsource ~/.bash_profileif you’re using Bash)
Step 4: Verify the setup
To make sure everything works, run these commands in Terminal:
adb version— This should output the Android Debug Bridge version (confirms platform-tools are in your PATH)echo $PATH— Check that your build tools path is listed in the output
Step 5: Restart and test
- Close and reopen Android Studio, plus any Terminal windows you have open
- Now try importing your Cordova/Ionic app again—the build tools error should be gone!
If you still run into issues, run cordova requirements android in Terminal to check for other missing dependencies (like specific SDK Platform versions) that might be holding you back.
内容的提问来源于stack exchange,提问作者JeffGallant

