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

Flutter Android许可状态未知,相关命令执行失败求助

Fixing Android License Status Unknown & SDK Manager Errors in Flutter

Hey there, let's tackle this issue step by step—since you're new to Flutter, I'll break everything down clearly so you can follow along easily.

First, Let's Diagnose the Root Causes

Your errors stem from two main issues:

  • Incorrect or unconfigured Android SDK path in your system environment variables
  • Missing/outdated Android SDK Command-line Tools that the sdkmanager relies on

Step 1: Confirm Your Android SDK's Exact Path

First, let's make sure you have the correct SDK path (this fixes the "path not found" error):

  1. Open Android Studio
  2. Go to File > Settings (Windows) or Android Studio > Settings (Mac)
  3. Search for Android SDK in the settings search bar
  4. Look at the SDK Location field—this is your full, correct SDK path (e.g., C:\Users\myusername\AppData\Local\Android\Sdk)

Note: Pay attention to capitalization (like Sdk vs sdk)—Windows is case-insensitive, but it's best to use the exact path from Android Studio.


Step 2: Configure System Environment Variables

This ensures your command line can find the SDK tools without typing the full path every time:

  1. Right-click This PC (Windows) > Properties > Advanced System Settings > Environment Variables
  2. Under System Variables, click New to add a new variable:
    • Variable name: ANDROID_HOME
    • Variable value: Paste the SDK path you copied earlier (e.g., C:\Users\myusername\AppData\Local\Android\Sdk)
  3. Edit the Path variable in System Variables:
    • Click Edit > New
    • Add these two entries:
      • %ANDROID_HOME%\tools\bin
      • %ANDROID_HOME%\platform-tools
  4. Click OK to save all changes, then close all open command prompt windows (critical—old windows won't pick up the new variables)

Step 3: Update Android SDK Command-line Tools

The "Could not find or load main class" error usually means you're missing the latest command-line tools. Fix this via Android Studio:

  1. Open Android Studio again
  2. Go to Tools > SDK Manager
  3. Switch to the SDK Tools tab
  4. Check the box next to Android SDK Command-line Tools (latest)
  5. Click Apply to download and install the tools
  6. Wait for the installation to finish, then close SDK Manager

Step 4: Run the License Command Again

Now let's verify everything works:

  1. Open a new command prompt window (important!)
  2. First, run flutter doctor—it should now recognize your Android SDK path correctly
  3. Then run flutter doctor --android-licenses
  4. When prompted, type y and press Enter for every license agreement to accept them all

Troubleshooting If It Still Doesn't Work

  • If you still get path errors, double-check that your ANDROID_HOME variable matches the exact SDK path from Android Studio
  • Try restarting your computer to ensure environment variables are fully applied
  • If the SDK Manager still fails, go back to Android Studio's SDK Manager and check for updates to Android SDK Tools and Android SDK Platform-Tools

内容的提问来源于stack exchange,提问作者Tim

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 09:28:47