Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting errors while adding launcher icon in flutter project?

So, I am trying change the default flutter launcher icon with my one. I am using the flutter_launcher_icons: ^0.9.2 from pub.dev. The code in pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  hexcolor: ^2.0.5
  google_fonts: ^2.1.0
  flutter_neumorphic: ^3.2.0
  flutter_launcher_icons: ^0.9.2

dev_dependencies:
  flutter_lints: ^1.0.4
  flutter_test:
    sdk: flutter

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

But when I am running flutter pub run flutter_launcher_icons:main, I am getting error saying:

  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.9.1)
  ════════════════════════════════════════════


✓ Successfully generated launcher icons
Unhandled exception:
FormatException: Invalid number (at character 1)

^

#0      int._handleFormatError (dart:core-patch/integers_patch.dart:129:7)
#1      int.parse (dart:core-patch/integers_patch.dart:55:14)
#2      minSdk (package:flutter_launcher_icons/android.dart:309:18)
#3      createIconsFromConfig (package:flutter_launcher_icons/main.dart:94:47)
#4      createIconsFromArguments (package:flutter_launcher_icons/main.dart:60:7)
#5      main (file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.2/bin/main.dart:6:26)
#6      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
pub finished with exit code 255

And the Icon doesn't change.

What probably the problem?

=> I mean, coz it worked many times before...

like image 409
MNBWorld Avatar asked Nov 19 '25 00:11

MNBWorld


2 Answers

Go to android/app/build.gradle and change the minSdkVersion and targetSdkVersion to integer values.

minSdkVersion 21
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

Then do the rest, i.e.

pub.get -> flutter pub run flutter_launcher_icons:main
like image 193
Justus Lolwerikoi Avatar answered Nov 20 '25 14:11

Justus Lolwerikoi


Another way to fix the issue, which also worked for me.

About

This error is mainly caused due to the android: true, when I tried after following many articles by using

(pubspec.yaml)

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

it worked only for ios, after which I got a recommendation code to be used for ios. I added.

flutter_icons:
  image_path: "images/icon.png" 
  android: false
  ios: true
  remove_alpha_ios: true  //recommendation added

Final Step

(Optional)

mistakes are done by me

Just check if you have written any extra code in the same file because I faced a lot of trouble due to my extra code in the file build.gradle.This line is used to fetch the value of flutter.minSdkVersion from the android\local.properties file.

def flutterminSdkVersion = localProperties.getProperty('flutter.minSdkVersion')

(android\app\build.gradle)

    minSdkVersion 16 
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName

And then running the usual code

flutter pub get 
flutter pub run flutter_launcher_icons:main

and I got the output

 ════════════════════════════════════════════
     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

ultimately the above code solves the issue, I hope anyone can get help from this and save his/her valuable time.

Attaching some sources, which helped me in the final verdict.

https://issueexplorer.com/issue/fluttercommunity/flutter_launcher_icons/301 https://github.com/fluttercommunity/flutter_launcher_icons/issues/88

like image 38
Spsnamta Avatar answered Nov 20 '25 13:11

Spsnamta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!