Flutter flutter_launcher_icons 图标生成插件[报错处理]

配置

dev_dependencies:
  flutter_launcher_icons: "^0.9.2"  //引入依赖


//配置图标
flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icon/icon.png"

执行生成

flutter pub get
flutter pub run flutter_launcher_icons:main

报错处理

错误内容:

 » flutter pub run flutter_launcher_icons:main
  ════════════════════════════════════════════
     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:310:18)
#3      createIconsFromConfig (package:flutter_launcher_icons/main.dart:94:47)
#4      createIconsFromArguments (package:flutter_launcher_icons/main.dart:60:7)
#5      main (file:///home/denis/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

Flutter Dart 版本:

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (3 months ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

解决:

通过替换这一行(~/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.2/lib/android.dart#308)

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

   final String minSdk = "21"; // line.replaceAll(RegExp(r'[^\d]'), '');
THE END
喜欢就支持一下吧
点赞15 分享