You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac运行Flutter Demo时flutter doctor报sdkmanager错误求助

Fixing 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 -version and javac -version in your terminal to confirm both commands return the same Java version.
  • Android SDK’s sdkmanager typically 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 jenv to manage multiple Java versions easily.
    • Or manually set your JAVA_HOME environment variable to point to your Java 8 installation in ~/.bash_profile or ~/.zshrc:
      export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_xxx.jdk/Contents/Home
      export PATH=$JAVA_HOME/bin:$PATH
      
    • Run source ~/.bash_profile (or source ~/.zshrc) to apply the changes, then test sdkmanager --version again.

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_profile or ~/.zshrc) and add these lines (replace your-username with 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 (or source ~/.zshrc), then test sdkmanager --version to 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:
    1. Open Android Studio, go to Preferences > Appearance & Behavior > System Settings > Android SDK.
    2. Switch to the SDK Tools tab.
    3. 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 sdkmanager with sudo long-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 --version again.
  • 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:28:32