Yassin Elshaiatany
Yassin Elshaiatany

Reputation: 323

flutter_launcher_icons not working Unhandled exception: FormatException: Invalid number (at character 1)

I want to change my app icon in flutter using flutter_launcher_icons: ^0.9.2
It shows me errors while I'm running Command flutter pub run flutter_launcher_icons:main
Image of the error


I tried many times but no new results

Upvotes: 32

Views: 12610

Answers (6)

Gedeon Mutshipayi
Gedeon Mutshipayi

Reputation: 4083

I just changed the package version in pubspec.yaml and that solved the problem for me.

dependencies:
  flutter_launcher_icons: ^0.10.0

Upvotes: 1

chitreshpratapsingh
chitreshpratapsingh

Reputation: 99

Inside file: ~/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.2/lib/android.dart

Replace Line:

 final String minSdk = line.replaceAll(RegExp(r'[^\d]'), '');
 To this:
 final String minSdk = "21"; // line.replaceAll(RegExp(r'[^\d]'), '');

Save the file and then run:

    flutter pub get
    flutter pub run flutter_launcher_icons:main

Source : https://github.com/fluttercommunity/flutter_launcher_icons/issues/324

Upvotes: 1

Oli
Oli

Reputation: 529

Thanks to this answer, I was able to fix the issue!

Upvotes: 3

Khang Vu Tien
Khang Vu Tien

Reputation: 21

The issue is explained in the readme of the plugin, section "Dependency incompatible". It says

Because flutter_launcher_icons >=0.9.0 depends on args 2.0.0 and flutter_native_splash 1.2.0 depends on args ^2.1.1, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash 1.2.0.
And because no versions of flutter_native_splash match >1.2.0 <2.0.0, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash ^1.2.0.
So, because enstack depends on both flutter_native_splash ^1.2.0 and flutter_launcher_icons ^0.9.0, version solving failed.
pub get failed

The solution is given in as cryptic a manner as the description above, but the simple hack given by @deffo worked for me. https://github.com/fluttercommunity/flutter_launcher_icons/issues/324#issuecomment-1013611137

What you do is that you skip the version solving done when the plugin reads build.gradle and you force minSdkVersion to be whatever version you prefer.

It's a hack but since you generate automatically the app icons only once and for all, who cares? :-)

BTW, the following solution seems cleaner but I didn't test it: https://github.com/fluttercommunity/flutter_launcher_icons/issues/262#issuecomment-877653847

Upvotes: -1

Deffo
Deffo

Reputation: 207

If the solution proposed by @Iagows doesn't work for you, have a look at this: flutter_launcher_icons-issues

Upvotes: 1

Iagows
Iagows

Reputation: 1099

I just had the same problem and solved doing this in android/app/build.gradle.

Changed:

minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion

To:

minSdkVersion 26
targetSdkVersion 30

Source

[Edit] After that, I could not run on emulator, so I changed back the gradle file (without running flutter_launcher_icon again). Now I have the app running and the icons are right.

Upvotes: 89

Related Questions