Flutter运行错误:您尚未接受许可协议 [英] Flutter run error : You have not accepted the license agreements
问题描述
我正在使用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.gradle
s individually.
推荐答案
尝试以下操作:
- 打开您的终端机
- 键入
flutter doctor --android-licenses
- 按
y
键接受每个许可证.
- Open your terminal
- type
flutter doctor --android-licenses
- press
y
to accept every license.
这篇关于Flutter运行错误:您尚未接受许可协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!