[英]Flutter sdk not found. The error in GradleException in the build.gradle
I am developing a flutter application and I am having certain errors.我正在开发一个 flutter 应用程序,但我遇到了某些错误。 The flutter SDK location is rightly provided but it says that Flutter SDK not found.正确提供了 flutter SDK 位置,但它说找不到 Flutter SDK。
The error is arising from the file build.gradle inside the android folder:该错误是由 android 文件夹中的文件 build.gradle 引起的:
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
I am even trying to change it but it says that "Cannot resolve symbol 'GradleExecption'".我什至试图改变它,但它说“无法解析符号'GradleExecption'”。 I am also having the same error in the AndroidManifest.xml file where I am specifying the "android:icon: drawable/app_logo.png" but it says that "Cannot resolve symbol 'drawable'".我在指定“android:icon: drawable/app_logo.png”的 AndroidManifest.xml 文件中也有同样的错误,但它说“无法解析符号‘drawable’”。
Can someone help me with this please?有人可以帮我吗?
也许尝试运行 Flutter Doctor 看看它给了你什么,如果这没有产生任何结果,然后尝试检查 Flutter 的 PATH 是否正确
1 if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } cntrl+Alt+S then show settings window then search flutter you can see in under language and framework .Add flutter sdk path. 1 if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } cntrl+Alt+S 然后显示设置窗口然后搜索 flutter 你可以看到在语言和框架下。添加 flutter sdk 路径。
Here you verify the above path and restart the ide(Android Studio) path :.android/local.properties这里验证一下上面的路径,重启ide(Android Studio)路径:.android/local.properties
2 I am also having the same error in the AndroidManifest.xml file where I am specifying the "android:icon: drawable/app_logo.png" but it says that "Cannot resolve symbol 'drawable'". 2 我在 AndroidManifest.xml 文件中也有同样的错误,我在其中指定了“android:icon: drawable/app_logo.png”,但它说“无法解析符号‘drawable’”。
check your path string add @withdrawable eg: android:icon="@drawable/app_logo.png"检查您的路径字符串添加@withdrawable 例如:android:icon="@drawable/app_logo.png"
remove the keyword new from Gradle.it will work before: throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")从 Gradle 中删除关键字 new。它之前会起作用:throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
after: throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")之后:抛出 GradleException(“未找到 Flutter SDK。在 local.properties 文件中使用 flutter.sdk 定义位置。”)
Try changing:尝试改变:
GradleException()
to:到:
FileNotFoundException()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.