Flutter运行错误:您尚未接受许可协议 [英] Flutter run error : You have not accepted the license agreements

查看:257
本文介绍了Flutter运行错误:您尚未接受许可协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google flutter 开发android和ios应用.
当我在pubspec.yaml中添加诸如shared_preferences的新依赖项,然后在终端中执行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].
  • What went wrong: A problem occurred configuring project ':shared_preferences'.
    You have not accepted the license agreements of the following SDK components: [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 ... \ AppData \ Roaming \ Pub \ Cache \ hosted \ pub.dartlang.org \ shared_preferences-0.3.1 \ android

C:\Users...\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\shared_preferences-0.3.1\android

并编辑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.gradles individually.

推荐答案

尝试以下操作:

  1. 打开您的终端机
  2. 键入flutter doctor --android-licenses
  3. y键接受每个许可证.
  1. Open your terminal
  2. type flutter doctor --android-licenses
  3. press y to accept every license.

这篇关于Flutter运行错误:您尚未接受许可协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆