flutter_launcher_icons的安装问题

kx1ctssn  于 2023-02-20  发布在  Flutter
关注(0)|答案(9)|浏览(186)

我添加了flutter包“flutter_launcher_icons”,但在尝试使用时遇到问题。
我的“pubspec.yaml”:

environment:
  sdk: ">=2.13.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_blue: ^0.8.0
  csv: ^5.0.0
  share: ^2.0.4
  path_provider: ^2.0.2
  flutter_launcher_icons: ^0.9.0
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icon/Logo.png" 
  adaptive_icon_background: "assets/launcher/background.png"
  adaptive_icon_foreground: "assets/launcher/foreground.png"

当我运行“pub get”时,我得到了这个(看起来不错):

C:\src\flutter\bin\flutter.bat --no-color pub get
Running "flutter pub get" in ble_thms...                           790ms
Process finished with exit code 0

但是当我尝试运行“flutter_launcher_icons”时,我得到了这个:

C:\src\flutter\packages\flutter_tools>flutter pub run flutter_launcher_icons:main
Could not find package "flutter_launcher_icons". Did you forget to add a dependency?
pub finished with exit code 65

当我尝试通过终端安装“flutter_launcher_icons”时,情况是一样的:

C:\src\flutter\packages\flutter_tools>flutter pub get flutter_launcher_icons
Running "flutter pub get" in ....                                  894ms

C:\src\flutter\packages\flutter_tools>flutter pub run flutter_launcher_icons:main
Could not find package "flutter_launcher_icons". Did you forget to add a dependency?
pub finished with exit code 65

我如何使用flutter_launcerh_icons软件包来解决这个问题呢?我也已经试过了“pub upgrade”和“pub outdated”。

9avjhtql

9avjhtql1#

添加依赖项**flutter_launcher_icons**,如下所示:

flutter pub add flutter_launcher_icons

然后:

flutter pub run flutter_launcher_icons:main

希望这对将来有同样问题的人有帮助。

0pizxfdo

0pizxfdo2#

该依赖项是dev依赖项,因此它必须位于dev_dependencies列表下。

dev_dependencies:
  flutter_launcher_icons: "^0.9.0"

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

开发依赖项不一定在“flutterrun”上运行,而是使用特定命令,如:
flutter发布运行flutter_launcher_icons:main -f“发布规范.yaml”
请参阅www.example.com上的安装指南pub.dev

mzmfm0qo

mzmfm0qo3#

您应该尝试使用以下依赖项:

flutter_launcher_icons: ^0.8.0

下面是您的pubspec.yaml文件:

dev_dependencies: 
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.8.0"

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

1.为指定路径准备应用程序图标。例如icon/icon.png
1.在终端上执行命令以创建应用程序图标:

flutter pub get

 flutter pub run flutter_launcher_icons:main
6yjfywim

6yjfywim4#

好的,看起来flutter_tools和对“图像”的依赖有问题

C:\src\flutter\packages\flutter_tools>flutter pub add flutter_launcher_icons
The current Dart SDK version is 2.13.4.

Because flutter_launcher_icons <0.4.0 requires SDK version >=1.20.1 <2.0.0 and flutter_launcher_icons >=0.4.0 <0.7.1 depends on image ^2.0.0, flutter_launcher_icons <0.7.1 requires image ^2.0.0.
And because flutter_launcher_icons >=0.7.1 <0.9.0 depends on yaml ^2.1.15 and flutter_launcher_icons >=0.9.0 depends on args 2.0.0, every version of flutter_launcher_icons requires args 2.0.0 or image ^2.0.0 or yaml ^2.1.15.
And because flutter_tools depends on both args 2.1.0 and yaml 3.1.0, every version of flutter_launcher_icons requires image ^2.0.0.
So, because flutter_tools depends on both image ^3.0.2 and flutter_launcher_icons any, version solving failed.

我可以以某种方式“降级”“flutter_tools”吗?

zkure5ic

zkure5ic5#

发现问题:
我不知怎么把Android Studio控制台中的路径改成了"C:\src\flutter\packages\flutter_tools",所以我把它改回了项目路径"C:\src\Android\AndroidStudioProjects\my_flutter_project"。
现在它起作用了。
愚蠢的错误,从我这边。:-(

x9ybnkn6

x9ybnkn66#

这是我解决问题的方法,在代码编辑器终端中键入以下命令:

flutter pub add package_name

或者,如果已经存在:

flutter pub upgrade package_name

希望能解决问题

798qvoo8

798qvoo87#

我得到了相同的错误,我发现我在命令行中写入了laucher而不是launcher

ohfgkhjo

ohfgkhjo8#

我刚刚解决了和你一样的错误,它是如此简单,以至于我们中的许多人有时没有意识到。

  • 验证终端是否位于项目文件夹中。
  • 尝试放置flutter_launcher_图标:dev_dependencies中的任何项:截面如图所示。
  • 验证pubspec.yaml中的压痕是否正确

click to see image

v1l68za4

v1l68za49#

我也有同样的问题,
Flutter清理
那么
Flutter 酒吧
解决了。

相关问题