错误:无法在pubspec.yaml中找到资产条目:“ assets / CupertinoIcons.ttf”

时间:2018-12-01 06:59:14

标签: android-studio flutter

将android studio升级到3.2.1和flutter插件后,我无法运行我的应用,出现以下错误:

Error: unable to locate asset entry in pubspec.yaml: "assets/CupertinoIcons.ttf".
Error building assets
flutter doctor -v
[√] Flutter (Channel dev, v0.10.1, on Microsoft Windows [Versión 10.0.17763.134], locale es-ES)
    • Flutter version 0.10.1 at c:\flutter
    • Framework revision 6a3ff018b1 (6 weeks ago), 2018-10-18 18:38:26 -0400
    • Engine revision 3860a43379
    • Dart version 2.1.0-dev.7.1.flutter-b99bcfd309

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\Alex\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 31.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] Connected device (3 available)
    • ONE E1005                 • *****      • android-arm   • Android 7.1.2 (API 25)
    • MIX                       • *****      • android-arm64 • Android 8.0.0 (API 26)
    • Android SDK built for x86 • emulator-5554 • android-x86   • Android 8.1.0 (API 27) (emulator)

• No issues found!

这是我的pubspec.yaml,我在其他机器上对该工程进行了测试,并且我认为代码没有问题。

name: flute_example
description: flute_example

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  flute_music_player: ^0.0.6

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:

  uses-material-design: true

  assets:
   - assets/lady.jpeg
   - assets/music_record.jpeg

4 个答案:

答案 0 :(得分:0)

cupertino_icons文件中查找.packages 并删除文件夹(没有lib

如果有

cupertino_icons:file:///Users/myuser/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.2/lib/

然后删除

cupertino_icons:file:///Users/myuser/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.2/

然后再次运行flutter packages get

答案 1 :(得分:0)

我对此有解决方案。请尝试以下代码。

如果我们在FontManifest.json文件中添加字体,则字体将应用于您的代码中。

这是一个代码,

FontManifest.json

[
 {
   "fonts": [
   {
     "asset": "fonts/MaterialIcons-Regular.ttf"
   }
],
   "family": "MaterialIcons"
},
   {
     "fonts": [
   {
      "asset": "fonts/MontserratSemiBold.ttf"
   }
 ],
   "family": "MontserratSemiBold"
 }
]

以上代码解决了我的2个Flutter网络问题,

(1)字体渲染和

(2)图标渲染

希望它也会为您提供帮助。 :)

答案 2 :(得分:0)

确保您的路径正确,否则可能会错过- / lib 。 最终路径如下所示:lib / assets / CupertinoIcons.ttf

答案 3 :(得分:0)

经过很长时间没有合理的解决方案,我决定删除pub缓存文件夹中的所有cupertino_icons文件夹(位于{flutter_installation_folder}\.pub-cache\hosted\pub.dartlang.org) 并且这保证了在使 Flutter clean command 和 re pub 获取项目后再次重新下载插件,并且它像魅力一样解决了! enter image description here