简体   繁体   English

Flutter sdk 未找到。 build.gradle中的GradleException错误

[英]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.

相关问题 Flutter android build.gradle 无法解析类 GradleException - Flutter android build.gradle unable to resolve class GradleException 错误:抛出新的 GradleException(“未找到颤振 SDK。在 local.properties 文件中使用 flutter.sdk 定义位置。”) - ERROR: throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") Android Studio Flutter 项目无法识别 GradleException 和 build.gradle 中的属性 - Android Studio Flutter project can not recognize GradleException and Properties in build.gradle Flutter build.gradle 错误“构建因异常而失败。” - Flutter build.gradle Error " Build failed with an exception." 在build.gradle中添加Facebook SDK时出错 - Getting error while adding Facebook SDK in build.gradle 将Facebook SDK添加到Android Studio build.gradle时出错 - Error when adding Facebook SDK to Android Studio build.gradle build.gradle 在 Visual Studio Code(Flutter) 中出错 - Error on build.gradle In Visual Studio Code(Flutter) 尝试运行 flutter 应用程序时,build.gradle 文件中出现错误 - When trying to run flutter application there is a Error in build.gradle file 应用程式build.gradle错误 - App build.gradle error Gradle 构建错误“未找到名称为‘默认’的配置。” - Gradle build error "Configuration with name 'default' not found."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM