Flutter flutter_launcher_icons error: pub finished with exit code 255
Asked Answered
P

7

8

I want to create my launcher icon for flutter. My config (pubspec.yaml) looks the following.

...
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  flutter_spinkit: ^5.1.0
  url_launcher: ^6.0.17
  http: ^0.13.4
  intl: ^0.17.0
  flutter_launcher_icons: ^0.9.2

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

I installed the flutter_launcher_icon via the console (flutter pub add flutter_launcher_icons). Afterwards I added the config (see above) to the pubspec.yaml file and entered the following two commands in the console:

flutter pub get
flutter pub run flutter_launcher_icons:main

as described in the documentation (https://pub.dev/packages/flutter_launcher_icons). But after the second command I get the following error message and pub finished with exit code 255.

  ════════════════════════════════════════════
     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:/Users/chris/AppData/Local/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

What do I do wrong?

Thanks!

Phrygian answered 6/1, 2022 at 18:35 Comment(0)
P
4

changing the minSdkVersion Number didn't work for me and it seems there is a bug in flutter_launcher_icons gitanswer. If I remove android:true from the config it created the iOS icon successfully.

I created and replaced the icons for android now manually. If you want to do that go in your project to projectname/android/app/src/res and replace the *png files in the folders starting with mipmap...

Br, Chris

Phrygian answered 12/1, 2022 at 10:19 Comment(2)
You need to set minSdkVersion to at least 19Sensational
Mine worked after removing 'android: true' and then I add 'ios: true' again run the command and it worked. You need to have 'minSdkVersion:21' (mine was 21, it should work others as well) otherwise it will through an error. If you use, 'flutter.minSdkVersion' in Gradle file, it will throw the error 'Unhandled exception: FormatException: Invalid number (at character 1)'Vern
G
12

Try changing the values of minSdkVersion to 23 and targetSdkVersion to 23. Then just run the following command: flutter pub run flutter_launcher_icons:main

example

Gurango answered 7/1, 2022 at 19:49 Comment(1)
Hey Gabiel, thanks for the answer but it still doesn't work. I still get the same error.Phrygian
E
5

In your project 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 run the following command

flutter pub get
flutter pub run flutter_launcher_icons:main
Evangelistic answered 7/1, 2022 at 6:45 Comment(1)
Hello Vishal_VE, thanks for the answer. When I changed the values I get two errors (Cannot resolve symbol 'Properties':1 AND Cannor resolve symbol 'GradleException':11). And when I run two commands after the changes I still get the same error :(.Phrygian
P
4

changing the minSdkVersion Number didn't work for me and it seems there is a bug in flutter_launcher_icons gitanswer. If I remove android:true from the config it created the iOS icon successfully.

I created and replaced the icons for android now manually. If you want to do that go in your project to projectname/android/app/src/res and replace the *png files in the folders starting with mipmap...

Br, Chris

Phrygian answered 12/1, 2022 at 10:19 Comment(2)
You need to set minSdkVersion to at least 19Sensational
Mine worked after removing 'android: true' and then I add 'ios: true' again run the command and it worked. You need to have 'minSdkVersion:21' (mine was 21, it should work others as well) otherwise it will through an error. If you use, 'flutter.minSdkVersion' in Gradle file, it will throw the error 'Unhandled exception: FormatException: Invalid number (at character 1)'Vern
A
2

If your app was created using version 2.8.0 of flutter sdk or higher then you might experience this problem too. In the android/app/build.gradle folder of your project you will see this:

minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion

I'm still researching where the values are being sourced from as at this date but to solve the issue replace the first line above with and the issue with app icons shall be solved once you run the commands prementioned.

minSdkVersion 21

For the splash screen image or icon, there's a folder named drawable-v21 in android/app/src/main/drawable-v21 that is where the flutter framework seemingly now manages the splash screen. Uncomment the code and point to your asset therein

Alvin answered 28/1, 2022 at 14:51 Comment(0)
D
0

It's interesting but you should also provide an icon for IOS. If you do not include image_path_ios: 'youricon.png', it gives that error.

So even if your app will not be in app store, just write your image path to there.

Darlington answered 18/2, 2022 at 17:4 Comment(0)
F
0

To complete understand the issue check this lines in the source code

// remove anything from the line that is not a digit
final String minSdk = line.replaceAll(RegExp(r'[^\d]'), '');

So if you have flutter.minSdkVersion in your build.gradle it won't work. as Gabriel Phelix suggested just use integer.

Floyfloyd answered 24/5, 2022 at 12:40 Comment(0)
D
0

Upgrading the plugin to version 0.9.3 has solved this issue for me. The changelog mentions that this was a problem since Flutter 2.8.0

Dextrorotation answered 19/7, 2022 at 20:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.