skip to Main Content

I changed the default flutter logo icon with a custom icon, but ended up messing up the alignment of the contents of the icon and wanted to change it again. I tried giving a new image path (path of the modified icon image) in flutter_icons (in pubspec.yaml file), but it didn’t work. I even tried changing the default icon files in the res folder (android->app->source->main->res) using an online icon generator, but that didn’t work either. Every time I change the icon files, I will run the commands: flutter pub get and flutter pub run flutter_launcher_icons:main to ensure icon changes are made.

PUBSPEC.YAML file (Old icon):
flutter_launcher_icons: ^0.12.0

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

PUBSPEC.YAML file (Icon which I want to use):
flutter_launcher_icons: ^0.12.0

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

But despite that, the icon I changed the first time is remains unchanged. I want to change my app icon to the modified image. I won’t require the steps to change the icon for iOS app, since the app is designed only for Android as of now. I don’t know where I am going wrong. Any help would be appreciated. Thanks in advance !

2

Answers


  1. If I understood your question correctly, the below suggestions should work.

    • Recheck whether that the new icon file assets/icon_foreground.png is
      located in the correct folder in your project directory. It is
      supposed to be in the assets folder at the root level of your
      project.

    • Also check that the flutter_icons plugin is installed and added to
      your pubspec.yaml file correctly. Run flutter pub get to ensure that
      all the dependencies are updated.

    • Try running flutter clean to clean the build artifacts, and then
      run flutter pub get and flutter pub run flutter_launcher_icons:main again.

    • Make sure that you’re running the app on a physical device or
      emulator that has been fully restarted after making the changes to
      the icon.

    • Try delete the old icon files from the res folder in your Android
      project, and then run flutter pub run flutter_launcher_icons:main
      again to regenerate the icon files.

    • Also check that you’re using the correct icon file name in the
      image_path parameter in your pubspec.yaml file. The file name and
      extension should be correct, and they should match the file name in
      your assets folder.

    Login or Signup to reply.
  2. In addition to the answer from @Messi, below is an example from my pubspec.yaml file in a sample project.
    Here, the icon.png is located in a directory (icons/) inside the assets folder.

    dev_dependencies:
      flutter_test:
        sdk: flutter
      flutter_launcher_icons: ^0.12.0
    flutter_icons:
      android: "launcher_icon"
      ios: true
      image_path: "assets/icons/icon.png"
      min_sdk_android: 21 # android min sdk min:16, default 21
    
    • Ensure the dependencies are correctly formatted. This can serve as a
      guide.

    You can equally create a new project and copy your libs and assets folder to the new project and the update your pubspec.yaml file and re-run then commands.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search