尝试运行我的应用程序时出现此错误。有任何想法吗? (下)
Launching lib\main.dart on SM J200Y in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\apk\debug\app-debug.apk.
Error detected in pubspec.yaml:
No file or variants found for asset: assets/credentials.json.
我已经检查了yaml文件,格式似乎还不错。我茫然想要这个问题。 (也在下面)
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/credentials.json
答案 0 :(得分:10)
检查资产的标识。通常,从新行开始应有3个空格。
assets:
- assets/credentials.json // <-- count three spaces from start
答案 1 :(得分:4)
有两种可能
答案 2 :(得分:3)
我遇到了同样的问题,但有两个错误:
答案 3 :(得分:0)
尝试不使用VS-Code或Android Studio手动复制文件。不要使用拖放操作。
答案 4 :(得分:0)
就我而言,问题/
不存在
首先,我添加了如下所示的图标路径。
assets:
- assets/icons
我通过在路径的末尾添加/
来解决此问题
assets:
- assets/icons/
答案 5 :(得分:0)
有时您需要输入文件名:
flutter: assets:
- lib/assets/logo.png