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

Flutter新手项目运行失败,未接受Android SDK许可证求解决

解决Flutter项目中Android SDK许可证未接受的问题

Hey there! This is a super common hiccup when you're starting out with Flutter and Android Studio—no need to worry, it's easy to fix. Let's walk through the solutions step by step.

Your core issue here is that your project requires Android SDK Build-Tools 28.0.3 and Android SDK Platform 28, but you haven't accepted their license agreements yet, which caused the Gradle build to fail.

方法一:通过Android Studio SDK Manager操作(最直观)

This is the most user-friendly way for beginners, with a simple graphical interface:

  • Open Android Studio, click Tools > SDK Manager in the top menu bar (or tap the SDK Manager icon that looks like a download arrow in the upper-right corner)
  • Switch to the SDK Platforms tab, find Android 9.0 (Pie) (which corresponds to API Level 28), make sure its checkbox is ticked, then click Apply in the bottom-right corner
  • Next, switch to the SDK Tools tab, find Android SDK Build-Tools 28.0.3, tick it, and click Apply again
  • A license agreement window will pop up—check the Accept option, then click Next and wait for the SDK components to download and install
  • Once installation finishes, go back to your Flutter project and click the run button to recompile

方法二:用命令行快速解决(适合偏好终端的用户)

If you run into issues with the GUI or prefer using the terminal, try this:

  1. Open Windows Command Prompt (CMD) or PowerShell
  2. Navigate to the tools/bin directory of your Android SDK. Your path is:
    cd C:\Users\MSI2\AppData\Local\Android\sdk\tools\bin
    
  3. Run the license acceptance command:
    sdkmanager --licenses
    
  4. You'll see a series of license agreements pop up one after another—type y and press Enter each time to accept all agreements
  5. Once all agreements are accepted, go back to Android Studio and re-run your Flutter project

额外小技巧:用Flutter Doctor检测问题

You can also open a terminal and run:

flutter doctor

It will automatically detect the unaccepted licenses and give clear prompts—just follow the instructions to fix the issue.


Your Flutter Code

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}

Error Message

Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 28 in C:\Users\MSI2\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Platform 28 not accepted.
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Failed to install the following Android SDK packages as some licences have not been accepted.
    build-tools;28.0.3 Android SDK Build-Tools 28.0.3
    platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: C:\Users\MSI2\AppData\Local\Android\sdk
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1

内容的提问来源于stack exchange,提问作者Huy Mụn

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 18:52:29