Home > Software design >  Launcher Icon not working even after getting "✓ Successfully generated launcher icons"
Launcher Icon not working even after getting "✓ Successfully generated launcher icons"

Time:03-09

I am trying to add a launcher icon to my flutter app. I have followed all the steps required to create a launcher icon.

This is my pubspec.yaml file

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.9.2

flutter_icons:
  android: true
  image_path_android: "icons/opicon.png"



  image_path: icons/opicon.png
  ios: true
  remove_alpha_ios: true

I have even made a change in android/app/build.gradle file

defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.loginpage"
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

I have even got a successful message from flutter

PS D:\Flutter_Projects\loginpage> flutter pub run flutter_launcher_icons:main
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.9.1)
  ════════════════════════════════════════════

• Creating default icons Android
• Overwriting the default Android launcher icon with a new icon
• Overwriting default iOS launcher icon with new icon

✓ Successfully generated launcher icons

But on the emulator, the launcher icon hasn't changed. It still has the default flutter icon.

This is the screenshot of the emulator

image

This is my project folder

enter image description here

The Highlighted folder is where I am having the icon image.

CodePudding user response:

Easiest way to change Launcher Icons,

Go to https://appicon.co/ and add your icon and generate it will give zip file, Extract this file and copy this folder and change in our project Android and Ios folder.

android - LOGINPAGE/android/app/src/main/res

ios - LOGINPAGE/ios/Runner

Then, add dependency

flutter_launcher_icons: ^0.9.2

Add,

flutter_icons:
  android: true
  ios: true
  image_path: "icons/opicon.png"
  remove_alpha_ios: true

run this command on terminal,

flutter pub get

flutter pub run flutter_launcher_icons:main

Then, it's done!

CodePudding user response:

In pubspec.yaml file-

dev_dependencies:
  flutter_launcher_icons: "^0.9.2"

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

and then run

flutter pub get flutter pub run flutter_launcher_icons:main

After creating icon successful, uninstall app and then flutter run.

  • Related