Flutter开发错误记录: Flutter SDK not found. Define location with flutter.sdk in the local.properties file.

问题描述

最近在Android原生项目添加flutter的module依赖时报了这个错误,错误内容是:
Caused by: org.gradle.api.GradleException: Flutter SDK not found. Define location with flutter.sdk in the local.properties file.

问题分析

分析了下报错信息,提示我们没找到Flutter SDK,需要在local.properties文件中使用flutter.sdk定义位置。

我本地明明有flutter SDK并且配置到了环境变量里,而且以前运行flutter项目也没报这个错,这次突然出现了,比较奇怪

问题解决

基于以上错误信息的提示,在Android 项目目录下的local.properties文件中添加上flutter SDK的位置,示例如下:

Mac环境:

sdk.dir=/Users/sunnysaini/Library/Android/sdk
flutter.sdk=/Users/sunnysaini/development/flutter

windows环境:

flutter.sdk=C\:\\flutter_sdk\\flutter_windows_1.17.5-stable\\flutter

注意: 示例中具体路径要基于本地flutter SDK的路径来添加;

问题搞定。
如果还有其他问题,欢迎留言讨论;

你可能感兴趣的:(Flutter开发错误记录: Flutter SDK not found. Define location with flutter.sdk in the local.properties file.)