Flutter 运行错误:您尚未接受许可协议 [英] Flutter run error : You have not accepted the license agreements
问题描述
我正在使用 Google flutter 开发 android 和 ios 应用.
当我将 shared_preferences
之类的新依赖项添加到 pubspec.yaml
然后在终端中执行 flutter run
时,出现此错误:
I'm developing android and ios app with Google flutter.
when I add a new dependency like shared_preferences
to pubspec.yaml
and then execute flutter run
in terminal, I got this error:
- 出了什么问题:配置项目:shared_preferences"时出现问题.
您尚未接受以下 SDK 组件的许可协议:[Android SDK Platform 27].
我知道为什么会这样!因为我系统上最新的 Android SDK 平台是 26 .它尝试下载 sdk 27,然后失败.没问题!我转到位于此处的库缓存文件夹:
I know why it happens! because the latest Android SDK platform on my system is 26 . it trys to download sdk 27 and then fails. no problem! I go to library cached folder which located here :
C:Users...AppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.3.1android
C:Users...AppDataRoamingPubCachehostedpub.dartlang.orgshared_preferences-0.3.1android
并编辑build.gradle
文件并将compileSdkVersion 27
更改为compileSdkVersion 26
.它有效.
到目前为止,我必须为所有新的依赖项执行此操作,
有什么方法可以为所有依赖项定义一个全局的 build.gradle 文件吗?这样就不需要单独编辑每个 buil.gradle
.
and edit build.gradle
file and change compileSdkVersion 27
to compileSdkVersion 26
. it works.
so far I have to do this for all new dependencies,
Is there any way such as defining a global build.gradle file for all dependencies? so no need to edit each buil.gradle
s individually.
推荐答案
试试这些:
- 打开你的终端
- 输入
flutter doctor --android-licenses
- 按
y
接受每个许可.
- Open your terminal
- type
flutter doctor --android-licenses
- press
y
to accept every license.
这篇关于Flutter 运行错误:您尚未接受许可协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!