Mac运行Flutter Demo时flutter doctor报sdkmanager错误求助
sdkmanager --version failed: 1 Error When Running flutter doctor --android-licenses on macOS 10.13.3 Hey there, let’s work through this frustrating error you’re facing. I’ve helped troubleshoot similar issues with Flutter and Android SDK tools on older macOS versions, so here are some actionable steps to try:
1. Verify Java Version Compatibility
Older macOS versions like 10.13.3 often have trouble with newer Java releases when paired with Android’s sdkmanager. Here’s what to do:
- Run
java -versionandjavac -versionin your terminal to confirm both commands return the same Java version. - Android SDK’s
sdkmanagertypically works best with Java 8 (either OpenJDK or Oracle JDK) on macOS 10.13.3. If you installed a newer Java version, try switching to Java 8:- You can use a tool like
jenvto manage multiple Java versions easily. - Or manually set your
JAVA_HOMEenvironment variable to point to your Java 8 installation in~/.bash_profileor~/.zshrc:export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH - Run
source ~/.bash_profile(orsource ~/.zshrc) to apply the changes, then testsdkmanager --versionagain.
- You can use a tool like
2. Correct Android SDK Environment Variables
Missing or misconfigured environment variables are a common culprit here:
- First, confirm your Android SDK path (usually
~/Library/Android/sdk). - Open your shell configuration file (
~/.bash_profileor~/.zshrc) and add these lines (replaceyour-usernamewith your actual username):export ANDROID_SDK_ROOT=/Users/your-username/Library/Android/sdk export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools - Save the file, run
source ~/.bash_profile(orsource ~/.zshrc), then testsdkmanager --versionto see if it works.
3. Update Android SDK Command-Line Tools
Outdated SDK tools can cause this error. Here’s how to update them:
- If you have Android Studio installed:
- Open Android Studio, go to Preferences > Appearance & Behavior > System Settings > Android SDK.
- Switch to the SDK Tools tab.
- Check Android SDK Command-line Tools (latest) and click Apply to install/update.
- If you don’t use Android Studio, run this command (once environment variables are set):
sdkmanager --update
4. Fix Directory Permissions
macOS’s strict permissions might block sdkmanager from accessing necessary files:
- Run this command to grant read/write access to your Android SDK directory:
sudo chmod -R 755 /Users/your-username/Library/Android/sdk - Avoid running
sdkmanagerwithsudolong-term, but you can test it once to rule out permission issues:sudo sdkmanager --version
5. Check for Proxy Interference
If you’re behind a proxy, sdkmanager might fail to connect to Google’s servers:
- Try temporarily disabling your proxy and running
sdkmanager --versionagain. - If you need to use a proxy, configure it directly for
sdkmanager:sdkmanager --proxy=http --proxy_host=your-proxy-address --proxy_port=your-proxy-port --version
If none of these steps resolve the issue, share the full error output you get when running sdkmanager --version, along with your Java version details and Android SDK path—this will help narrow down the problem further.
内容的提问来源于stack exchange,提问作者Graham Hobson

