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

Home Page:https://pub.dev/packages/flutter_launcher_icons

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] RangeError (index): Index out of range: index should be less than 9216: 9252

jerwin-fernandez opened this issue Β· comments

ℹ️ Info

Version: ^0.13.1

πŸ’¬ Description

When running this command flutter pub run flutter_launcher_icons I am getting this error RangeError (index): Index out of range: index should be less than 9216: 9252

Deprecated. Use dart run instead.
════════════════════════════════════════════
FLUTTER LAUNCHER ICONS (v0.13.1)
════════════════════════════════════════════

β€’ Creating default icons Android
β€’ Adding a new Android launcher icon

βœ• Could not generate launcher icons
RangeError (index): Index out of range: index should be less than 9216: 9252

πŸ“œ Pubspec.yaml

flutter_launcher_icons:
android: 'launcher_icon'
ios: true
image_path: 'images/icon/icon.png'
min_sdk_android: 21 # android min sdk min:16, default 21

I have the same problem, and I just upgraded flutter. Maybe flutter_launcher_icons is not compatible with the latest flutter version?

Below is my flutter doctor -v

[βœ“] Flutter (Channel stable, 3.13.5, on Ubuntu 23.04 6.2.0-33-generic, locale en_US.UTF-8)
    β€’ Flutter version 3.13.5 on channel stable at /home/wiky/local/flutter
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision 12fccda598 (5 days ago), 2023-09-19 13:56:11 -0700
    β€’ Engine revision bd986c5ed2
    β€’ Dart version 3.1.2
    β€’ DevTools version 2.25.0

[βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    β€’ Android SDK at /home/wiky/local/android-sdk
    β€’ Platform android-33, build-tools 33.0.2
    β€’ Java binary at: /home/wiky/local/android-studio/jbr/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    β€’ All Android licenses accepted.

[βœ“] Chrome - develop for the web
    β€’ Chrome at google-chrome

[βœ“] Linux toolchain - develop for Linux desktop
    β€’ Ubuntu clang version 15.0.7
    β€’ cmake version 3.25.1
    β€’ ninja version 1.11.1
    β€’ pkg-config version 1.8.1

[βœ“] Android Studio (version 2022.3)
    β€’ Android Studio at /home/wiky/local/android-studio
    β€’ Flutter plugin version 75.1.2
    β€’ Dart plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart
    β€’ Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[βœ“] VS Code (version 1.82.2)
    β€’ VS Code at /usr/share/code
    β€’ Flutter extension version 3.72.0

[βœ“] Connected device (2 available)
    β€’ Linux (desktop) β€’ linux  β€’ linux-x64      β€’ Ubuntu 23.04 6.2.0-33-generic
    β€’ Chrome (web)    β€’ chrome β€’ web-javascript β€’ Google Chrome 117.0.5938.88

[βœ“] Network resources
    β€’ All expected network resources are available.

β€’ No issues found!

And below is pubspec.yaml

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0
  flutter_launcher_icons: ^0.13.1

flutter_launcher_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/images/logo.png"
  min_sdk_android: 21 # android min sdk min:16, default 21
  remove_alpha_ios: true
  web:
    generate: true
    background_color: "#hexcode"
    theme_color: "#hexcode"
  windows:
    generate: true
    icon_size: 48 # min:48, max:256, default: 48
  macos:
    generate: true

I have another project that was created before I upgraded flutter, and it's OK to run flutter_launcher_icons.

But once I clean the flutter cache, error occurs.

dart run flutter_launcher_icons  # successfully, no error at all

flutter clean
flutter pub get 

dart run flutter_launcher_icons  # that error occurs

Same issue. Did you find any solution?

add or modify the image dependency: image: 4.0.17

add or modify the image dependency: image: 4.0.17

It works, Thank you.

I'm still encountering this error. I attempted to use the image version 4.0.17, but the issue persists.

flutter_launcher_icons:
  image_path: images/appicon.png
  adaptive_icon_background: images/appicon-background.png
  adaptive_icon_foreground: images/appicon-foreground.png
  android: true
  ios: true
  remove_alpha_ios: true

@jerwin-fernandez, Thanks for reporting this! We had the same issue too and "fixed" it by hard coding image in pub spec in flutter (e.g., to "image: 4.1.0"). However, since we do not want to keep our project hard codded to "image: 4.1.0" forever and allow it to upgrade to newer versions, can you open this issue so that the "flutter_launcher_icons" team can find a maintainable fix? For example, a fix where "flutter_launcher_icons" is compatible with the latest image package.
Thoughts?

@jerwin-fernandez, Thanks for reporting this! We had the same issue too and "fixed" it by hard coding image in pub spec in flutter (e.g., to "image: 4.1.0"). However, since we do not want to keep our project hard codded to "image: 4.1.0" forever and allow it to upgrade to newer versions, can you open this issue so that the "flutter_launcher_icons" team can find a maintainable fix? For example, a fix where "flutter_launcher_icons" is compatible with the latest image package. Thoughts?

reopening the issue.

still getting the error with the config from example

flutter_launcher_icons:
  android: "launcher_icon"
  ios: true
  image_path: "launcher/launcher.png"
  min_sdk_android: 21

Built flutter_launcher_icons:flutter_launcher_icons.
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.13.1)
  ════════════════════════════════════════════

β€’ Creating default icons Android
β€’ Adding a new Android launcher icon

βœ• Could not generate launcher icons
RangeError (index): Index out of range: index should be less than 9216: 9224

upd: adding image 4.0.17 helps but still..

@khojiakbar17 Where did you add the image: 4.0.17? You have to add it to the flutter_launcher_icons package itself and run flutter clean and flutter pub get command.

bug in dependency: image, already fixed in latest version 4.1.3
no need to override image version again

brendan-duncan/image#575 (comment)

bug in dependency: image, already fixed in latest version 4.1.3 no need to override image version again

brendan-duncan/image#575 (comment)

remove the hard-coded dependency of image: 4.0.17 on pubspec.yaml

clean dependency
flutter clean

install dependency
flutter pub get

Resolving dependencies...
collection 1.17.2 (1.18.0 available)
image 4.0.17 (4.1.3 available)
material_color_utilities 0.5.0 (0.8.0 available)
meta 1.9.1 (1.10.0 available)
petitparser 5.4.0 (6.0.1 available)
stack_trace 1.11.0 (1.11.1 available)
stream_channel 2.1.1 (2.1.2 available)
test_api 0.6.0 (0.6.1 available)
web 0.1.4-beta (0.2.1-beta available)
xml 6.3.0 (6.4.2 available)
Got dependencies!

upgrade image dependency
flutter pub upgrade image

run flutter launcher icons
flutter pub run flutter_launcher_icons