fluttercommunity / flutter_launcher_icons

Flutter Launcher Icons - A package which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future. Maintainer: @MarkOSullivan94
https://pub.dev/packages/flutter_launcher_icons
MIT License
2k stars 400 forks source link

Invalid version constraint #81

Closed blackbeario closed 5 years ago

blackbeario commented 5 years ago

When trying to run flutter packages pub run flutter_launcher_icons:main it fails with the error Error on line 41, column 15 of pubspec.yaml: Invalid version constraint: Could not parse version "assets/images/icon.png". Unknown text at "assets/images/icon.png". image_path: "assets/images/icon.png".

Of course, I do have the file with the name icon.png in this directory.

The respective part of my pubspec.yaml file looks like this:


  flutter_icons:
  image_path: 'assets/images/icon.png'
  android: true
  ios: true

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
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/
milodude commented 5 years ago

If you see the assets section, you should set the path to the file you wanna include in your flutter project. I believe in your example should be `assets:

blackbeario commented 5 years ago

@milodude thanks for your reply. Leaving the assets section as - assets/ is supposed to be a catch-all for everything inside the assets folder. My other images inside assets are loaded in other parts of my app. However, I tried adding this for a test, and I'm still getting the same error unfortunately.

assets:
    - assets/images/icon.png
MarkOSullivan94 commented 5 years ago

From a quick look at your yaml config, it looks like your indentation is incorrect unless you pasted it in wrong.

See this as an example: https://github.com/fluttercommunity/flutter_launcher_icons/blob/master/example/pubspec.yaml

blackbeario commented 5 years ago

I think that's just the markdown conversion or a paste issue. The first comment in this issue shows it as it actually is. 2 space indentation throughout. I referred to the example and tried several various attempts. Each is giving me the same result. I even tried replacing the png file, thinking maybe that could be the problem.

Here is the entire yaml file:

name: mobile
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  flutter_localizations:
    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
  rxdart: ^0.18.1
  firebase_core: ^0.2.5+1
  firebase_auth: ^0.6.2+1
  cloud_firestore: ^0.8.2+1
  tuple: ^1.0.1
  flutter_simple_dependency_injection: ^0.0.5
  package_info: ^0.3.2
  shared_preferences: ^0.4.2
  meta: ^1.1.6
  url_launcher : ^5.0.1

  bloc:
    path: ../bloc

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: ^0.7.0

  flutter_icons:
  image_path: 'assets/images/icon.png'
  android: true
  ios: true

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
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/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.io/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.io/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.io/custom-fonts/#from-packages
blackbeario commented 5 years ago

The error message seems like it's looking for a version number instead of an image path/file? Could not parse version "assets/images/icon.png"

MarkOSullivan94 commented 5 years ago

Appreciate you sharing your yaml config

  flutter_icons:
  image_path: 'assets/images/icon.png'
  android: true
  ios: true

There seems to be no indentation after the flutter_icons:, try copy and pasting this into your yaml config.

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

It definitely seems like a yaml config issue because I'm seeing other related issues to that error on Google

blackbeario commented 5 years ago

You're absolutely right! I just realized my indentation mistake while comparing your example yaml file.

Sorry for the issue, but thank you so much for your incredibly quick replies and for the package!

MarkOSullivan94 commented 5 years ago

I'm glad that was the issue! Happy to help.

@milodude thanks for stepping in and trying to help! Always appreciate others helping me out 🙌

blackbeario commented 5 years ago

@milodude I did need to an another entry for assets/images however.

To include all assets under a directory, specify the directory name with the / character at the end:

flutter:
assets:
- assets/

Note that only files located directly in the directory will be included; to add files located in subdirectories, create an entry per directory.

^^ from https://flutter.io/docs/development/ui/assets-and-images