flutterdartvisual-studio-code

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


Solution

  • 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