简体   繁体   English

无法预编译 flutter_launcher_icons:main:

[英]Failed to precompile flutter_launcher_icons:main:

So I tried using flutter_launcher_icons to automatically change the launcher icon of my simple interest calculator app.所以我尝试使用 flutter_launcher_icons 来自动更改我的简单兴趣计算器应用程序的启动器图标。

This is my code in pubspec.yaml这是我在 pubspec.yaml 中的代码


dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.0
  flutter_launcher_icons: ^0.8.1

dev_dependencies:

  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.8.0"

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icon.png"

flutter:
  uses-material-design: true

The Error I got after running flutter pub get & flutter pub run flutter_launcher_icons:main运行 flutter pub get & flutter pub run flutter_launcher_icons:main 后出现的错误

Failed to precompile flutter_launcher_icons:main:
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:1:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hosted/
pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.

import 'package:image/image.dart';
       ^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/android.dart:4:8: Error: Error when reading '/C:/src/flutter/flutter/.pub-cache/hoste
d/pub.dartlang.org/image-2.1.19/lib/image.dart': The system cannot find the path specified.

import 'package:image/image.dart';
       ^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/utils.dart:3:1: Error: Type 'Image' not found.
Image createResizedImage(int iconSize, Image image) {
^^^^^
                                                 ^^^^^
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.8.1/lib/ios.dart:93:1: Error: Type 'Image' not found.
Image createResizedImage(IosIconTemplate template, Image image) {
^^^^^
pub finished with exit code 1

you can change it like that;你可以这样改变它;

flutter_icons:
  android: true
  ios: true
  image_path: "assets/icon.png"

and no need to use that import 'package:image/image.dart';并且不需要使用那个 import 'package:image/image.dart'; if you take your image from assets no need to import it like that.如果您从资产中获取图像,则无需像那样导入它。 you should create a file named assets and put image in it您应该创建一个名为 assets 的文件并将图像放入其中

after that just paste that in terminal.之后只需将其粘贴到终端中。

flutter pub run flutter_launcher_icons:main

You did not import flutter_launcher_icons package correctly under dev_dependencies .您没有在 dev_dependencies 下正确导入flutter_launcher_icons dev_dependencies You should not use quotes("). You can edit that part with the following one:您不应该使用引号(“)。您可以使用以下内容编辑该部分:

dev_dependencies:

  flutter_test:
    sdk: flutter

  flutter_launcher_icons: ^0.8.0

In my case the image package was not being correctly downloaded, so I went to ~\flutter.pub-cache\hosted\pub.dartlang.org\image-3.0.8 and cloned the rep from git: https://github.com/brendan-duncan/image在我的情况下,图像 package 没有被正确下载,所以我去了 ~\flutter.pub-cache\hosted\pub.dartlang.org\image-3.0.8 并从 git 克隆了代表: Z5E0556C500A187B com/brendan-duncan/图像

After that the command worked.之后,该命令起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter flutter_launcher_icons 出错 - error with flutter flutter_launcher_icons 安装flutter_launcher_icons的问题 - Issue with the installation of flutter_launcher_icons flutter_launcher_icons 不起作用(应用启动器图标损坏/崩溃) - flutter_launcher_icons not working (app launcher icon broken/crashed) Flutter “flutter_launcher_icons 0.9.3” android 图标现在可以工作了 - Flutter "flutter_launcher_icons 0.9.3" android icon now working 我们应该在使用后删除 flutter_launcher_icons 吗? - Should we remove flutter_launcher_icons after its use? 添加 flutter_launcher_Icons 后,gradle 构建失败 - After adding flutter_launcher_Icons gradle build fails flutter_launcher_icons — 在 pubspec.yaml 中检测到错误: - flutter_launcher_icons — Error detected in pubspec.yaml: 启动图标看起来不像预期的那样 // flutter_launcher_icons - Launch icon doesn't look as intended // flutter_launcher_icons pub get failed (1; 所以,因为 fstore 依赖于 flutter_launcher_icons 0.8.1 和 cached_network_image 2.5.1,版本求解失败。) - pub get failed (1; So, because fstore depends on both flutter_launcher_icons 0.8.1 and cached_network_image 2.5.1, version solving failed.) Flutter:运行此代码后删除flutter_native_splash和flutter_launcher_icons的代码是否安全? - Flutter: Is it safe if I remove the code of flutter_native_splash & flutter_launcher_icons after run this code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM