在 Android Studio 中构建文件时出现颤振错误
Posted
技术标签:
【中文标题】在 Android Studio 中构建文件时出现颤振错误【英文标题】:Flutter error on building files in Android Studio 【发布时间】:2020-08-23 01:36:00 【问题描述】:我在 android Studio 上新安装了 Flutter。我有一个颤振的源代码,我想用它打开它。我安装了最新的颤振插件和颤振 SDK。但是当我尝试运行该应用程序时,它会显示以下错误:
Compiler message:
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
PictureStream();
^^^^^^^^^^^^^
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable
^
Compiler message:
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
PictureStream();
^^^^^^^^^^^^^
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Flutter SDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Flutter SDK\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
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 23s
Exception: Gradle task assembleDebug failed with exit code 1
我对此完全陌生,不知道这个错误指向哪里。我有最新的 Flutter SDK 版本:Flutter 1.17.0 和 Dart 2.8.1,它是一个稳定的版本。我的 Android Studio 版本是 3.6.2
【问题讨论】:
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。 【参考方案1】:尝试在您的终端中执行此操作:
flutter pub cache repair
如果它不起作用,删除颤振文件夹以及缓存文件夹应该可以完成这项工作。
【讨论】:
终端错误:'flutter' 未被识别为内部或外部命令、可运行程序或批处理文件。 @dhruvbhati:可以搜索该错误 - 它在 Windows 上很常见。 嘿,我在终端中运行了代码,但收到此错误:重新安装了 181 个软件包。无法重新安装 2 个软件包:-图像 2.1.12-video_player 0.10.6 pub 已完成,退出代码为 69 有什么办法可以只重新安装这两个,没有正确安装。如果它不起作用,那么你能告诉我颤振文件夹的位置和要删除的缓存文件夹吗 成功完成缓存修复,但错误未解决。请尽快帮助我。谢谢【参考方案2】:在我的情况下,我解决了这个问题,将最新版本的 Flutter svg 添加到 pubspec.yaml
查看链接以安装最新版本:https://pub.dev/packages/flutter_svg#-installing-tab-
【讨论】:
以上是关于在 Android Studio 中构建文件时出现颤振错误的主要内容,如果未能解决你的问题,请参考以下文章
在 Android Studio 中使用 AsyncTask 解析在线 XML 文件时出现 NetworkOnMainThreadException
Android studio,构建kotlin时出现奇怪错误:生成错误代码
Android Studio 在运行 Flutter 项目时出现问题
在 Android Studio 中设置 Flutter 时出现问题