Flutter:找不到SDK位置.在local.properties文件中使用sdk.dir或使用ANDROID_HOME环境变量定义位置 [英] Flutter: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable
问题描述
我正在以不同的方式构建应用程序,两项工作均成功,但其中一项失败.
I'm building app using different ways, two works but one fails.
方法:1(有效)
flutter build appbundle
方法:2(有效)
在Android Studio中打开模块,然后选择
Opening module in Android Studio, after that, choosing
Build > Generate Signed Bundle/APK... > filling all info afterwards
在这种情况下,我能够构建应用程序捆绑包和APK文件.
In this case, I am able to build both app bundle and APK file.
方法:3(无效)
flutter build apk
我收到此错误:
失败:生成失败,发生异常. * 什么地方出了错: 配置根项目"android_intent"时出现问题.
FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring root project 'android_intent'.
SDK位置.在local.properties文件中使用sdk.dir或使用ANDROID_HOME环境变量来定义位置.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
如果我删除了android_intent
,则我在其他软件包中开始出现错误,因此绝对不是问题.我再次检查了我是否有
If I remove android_intent
, I start getting error in other packages, so definitely the package isn't a problem. I double checked that I have
local.properties
,gradle.properties
和settings.gradle
.
我的其他项目似乎也能正常工作.
And my other projects seem to work.
推荐答案
有时您会从需要最新gradle才能实际运行的插件中看到SDK问题.
即使我的SDK设置正确,我也遇到了这个问题:
找不到SDK位置.在sdk.dir中定义位置 local.properties文件或带有ANDROID_HOME环境变量.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
更多信息来自:
这是一个插件故障的示例,它将导致sdk和查询错误 flutter_file_picker :
Build is failing with unexpected element <queries> found in <manifest>.
升级gradle:
要在Flutter项目中升级gradle,请文件->打开,然后选择Flutter应用程序中包含的Android文件夹.完成加载后,它将提示您将gradle升级到最新版本.这样可以解决问题
To upgrade gradle in a flutter project, File -> Open and select the Android folder which is part of your Flutter application. When that finishes loading, it will prompt you to upgrade gradle to the latest version. This will resolve the issue
这篇关于Flutter:找不到SDK位置.在local.properties文件中使用sdk.dir或使用ANDROID_HOME环境变量定义位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!