[英]Issue with the installation of flutter_launcher_icons
I added the flutter package "flutter_launcher_icons" but get problems when try to use it.我添加了 flutter package "flutter_launcher_icons" 但是在尝试使用它时遇到问题。
My "pubspec.yaml":我的“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"
When I run "pub get" I get this (looks OK):当我运行“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
But when I try to run the "flutter_launcher_icons" I get this:但是当我尝试运行“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
When I try to install "flutter_launcher_icons via terminal its the same:当我尝试通过终端安装“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
How can I solve this problem to use the package "flutter_launcerh_icons"?如何使用 package“flutter_launcherh_icons”解决这个问题? I also already tried "pub upgrade" and "pub outdated".我也已经尝试过“pub upgrade”和“pub outdated”。
You should be try to use below dependency:您应该尝试使用以下依赖项:
flutter_launcher_icons: ^0.8.0
Below is your pubspec.yaml
file:以下是您的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
Prepare an app icon for the specified path.为指定路径准备一个应用程序图标。 eg icon/icon.png例如 icon/icon.png
Execute command on the terminal to Create app icons:在终端上执行命令来创建应用程序图标:
flutter pub get flutter pub run flutter_launcher_icons:main
OK, it seems that there is a problem with the flutter_tools and the dependence on "image" OK,看来是flutter_tools有问题,对“image”的依赖
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.
Can I "downgrade" somehow the "flutter_tools" ?我可以以某种方式“降级”“flutter_tools”吗?
The dependency is dev dependency, so it must go under dev_dependencies list.依赖是 dev 依赖,所以它必须在 dev_dependencies 列表下。
dev_dependencies:
flutter_launcher_icons: "^0.9.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
Dev dependency are not necessarily ran on "flutter run", but rather with specific command, like:开发依赖项不一定在“flutter run”上运行,而是使用特定命令运行,例如:
flutter pub run flutter_launcher_icons:main -f "pubspec.yaml' flutter pub run flutter_launcher_icons:main -f "pubspec.yaml'
Please refer to installation guide on pub.dev请参考pub.dev上的安装指南
Found the problem:发现问题:
I somehow changed the path in the Android Studio Console to "C:\\src\\flutter\\packages\\flutter_tools".我以某种方式将 Android Studio 控制台中的路径更改为“C:\\src\\flutter\\packages\\flutter_tools”。 So I changed it back to the project path "C:\\src\\Android\\AndroidStudioProjects\\my_flutter_project".所以我把它改回项目路径“C:\\src\\Android\\AndroidStudioProjects\\my_flutter_project”。
Now it is working.现在它正在工作。
Clumsy mistake from my side.我这边的笨拙错误。 :-( :-(
我遇到了同样的错误,我发现我在命令行中使用了 laucher 而不是启动器
注意分号和主之间的空间,即 (flutter pub run flutter_launcher_icons: main) 不起作用,但 flutter pub run flutter_launcher_icons:main 有效,只是我认为你应该知道的一个提示
听听我是如何解决我的问题的,在你的代码编辑器终端输入以下命令 flutter pub add package_name 或输入: flutter pub upgrade package_name 如果它已经存在希望它会解决问题
Flutter said that I "Could not find package " flutter_launcher_icons<\/strong> ". Did you forget to add a dependency?" Flutter 说我“找不到包” flutter_launcher_icons<\/strong> “。你忘记添加依赖了吗?”
reply flutter by adding the dependency flutter_launcher_icons<\/strong> like so通过像这样添加依赖flutter_launcher_icons<\/strong>来回复flutter
flutter pub add flutter_launcher_icons颤振酒吧添加颤振启动器图标
then然后
flutter pub run flutter_launcher_icons:main颤振酒吧运行颤振启动器图标:主要
Hope this helps and with anyone with the same issues in the future.希望这对将来有同样问题的人有所帮助。
"I just solved the same error you have, and it was something so simple that many of us do not realize it sometimes.我刚刚解决了您遇到的相同错误,而且它非常简单,以至于我们中的许多人有时都没有意识到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.