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

Android SDK许可证未接受导致项目构建失败求助

Android SDK许可证未接受导致项目构建失败求助

嗨,我看你遇到了Android项目构建失败的问题,根源是没接受SDK相关组件的许可证协议,别担心,这问题很好解决!先看看你遇到的具体错误日志:

Checking the license for package Android SDK Tools in C:\Users\pc\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Tools not accepted.
Checking the license for package Android SDK Build-Tools 30.0.3 in C:\Users\pc\AppData\Local\Android\sdk\licenses
Warning: License for package Android SDK Build-Tools 30.0.3 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.
  tools Android SDK Tools
  build-tools;30.0.3 Android SDK Build-Tools 30.0.3
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  All licenses can be accepted using the sdkmanager command line tool:
  sdkmanager --licenses

解决方法

方法一:使用命令行工具sdkmanager

这是最快捷的方式,步骤如下:

  1. 找到你的Android SDK安装路径里的sdkmanager工具,一般在C:\Users\pc\AppData\Local\Android\sdk\cmdline-tools\latest\bin(如果是旧版本SDK,可能在tools\bin目录下)
  2. 打开Windows命令提示符(CMD)或者PowerShell,切换到这个目录
  3. 执行命令:sdkmanager --licenses
  4. 之后会依次弹出各个许可证协议,每次输入y并回车,直到所有协议都接受完成

方法二:通过Android Studio的SDK Manager操作

如果你更习惯图形界面操作,可以这样做:

  1. 打开Android Studio并加载你的项目
  2. 点击顶部菜单栏的Tools -> SDK Manager
  3. 在弹出的窗口中切换到SDK Tools标签页
  4. 在列表里找到Android SDK Tools和Android SDK Build-Tools 30.0.3,勾选它们
  5. 点击Apply按钮,这时会弹出许可证协议窗口,勾选“接受协议”选项,然后点击OK,等待组件安装和许可证确认完成

完成以上任意一种方法后,重新构建你的项目,应该就能正常运行啦!

备注:内容来源于stack exchange,提问作者Jude Ofosu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.17 11:13:02