异常:Gradle 任务 assembleDebug 失败,退出代码为 1,Visual Studio 代码
Posted
技术标签:
【中文标题】异常:Gradle 任务 assembleDebug 失败,退出代码为 1,Visual Studio 代码【英文标题】:Exception: Gradle task assembleDebug failed with exit code 1, visual studio code 【发布时间】:2021-06-09 06:54:49 【问题描述】:我的应用程序运行正常,运行颤振升级后它给了我这个错误。我没有更改代码中的任何内容。 注意:我正在使用 Visual Studio 代码 我试过颤振清洁,颤振升级,但它给出了同样的错误。 我检查了JAVA_HOME路径,没问题
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.1/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name
'nullOk'.
context != null ? Localizations.localeOf(context, nullOk: true) : null,
^^^^^^
../../flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
static Locale localeOf(BuildContext context)
^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\mobileapps\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\mobileapps\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 49s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 50.5s
Exception: Gradle task assembleDebug failed with exit code 1
这是运行医生 -v 的结果
[√] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.18362.30], locale en-US)
• Flutter version 2.0.1 at D:\mobileapps\flutter
• Framework revision c5a4b4029c (7 days ago), 2021-03-04 09:47:48 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[√] android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\hit-ham\AppData\Local\Android\sdk
• Platform android-29, build-tools 30.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
rosoft VS Code
• Flutter extension version 3.20.0
[√] Connected device (2 available)
• GM1910 (mobile) • bb671501 • android-arm64 • Android 10 (API 29)
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.190
• No issues found!
【问题讨论】:
【参考方案1】:您应该将包“flutter_svg”从 0.18.1 更新到 0.19.3,它应该可以解决您的问题, 发生这种情况是因为 Flutter 2 中删除了“nullOk”参数。您可以在此处阅读: https://flutter.dev/docs/release/breaking-changes/eliminating-nullok-parameters
我找到了这个解决方案,它对我有用
【讨论】:
非常感谢。你的回答救了我的命。这是一个非常愚蠢的问题,但显示出很大的错误。再次感谢大家以上是关于异常:Gradle 任务 assembleDebug 失败,退出代码为 1,Visual Studio 代码的主要内容,如果未能解决你的问题,请参考以下文章
如何解决此错误异常:Gradle 任务 assembleDebug 失败,退出代码为 1
Gradle 在从网络下载工件时抛出错误.. 异常:Gradle 任务 assembleDebug 失败,退出代码为 1
Gradle 任务 assembleDebug 失败,退出代码为 1(运行时异常)
android studio 异常:Gradle 任务 assembleDebug 失败,退出代码为 1