Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] flutter pub run flutter_launcher_icons:main -->FormatException: Invalid number (at character 1) #351

Closed
ghost opened this issue Mar 22, 2022 · 18 comments · Fixed by #322

Comments

@ghost
Copy link

ghost commented Mar 22, 2022

ℹ️ Info

Version: ^0.9.2

💬 Description

rajkumar@rkmint ~]> 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: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:///home/rajkumar/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.2/bin/main.dart:6:26)
#6 _delayEntrypointInvocation. (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

📜 Pubspec.yaml

name: magichuman
description: Fasting tracker app for daily monitoring and health improvement
s.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

/CoreFoundationKeys.html
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"

dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
shared_preferences: ^2.0.13
share_plus: ^3.1.0
flutter_local_notifications: ^9.4.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.2

flutter_lints: ^1.0.0

flutter_icons:
android: "launcher_icon"
ios: false
image_path: "assets/yoga_launcher_icon.png"

flutter:
uses-material-design: true

@ghost ghost changed the title [BUG] [BUG] flutter pub run flutter_launcher_icons:main -->FormatException: Invalid number (at character 1) Mar 22, 2022
@ghost
Copy link
Author

ghost commented Mar 22, 2022

i am using the latest version of Flutter

@MustafaDev-shaikh
Copy link

Same issue everything changed in build.gradle file same error but when I change android : true to false successful but no App icon created

Version : flutter_launcher_icons: "^0.9.2"

@devaskim
Copy link

devaskim commented Mar 22, 2022

The issue in code is here. It is expected to be an integer but in my case it is a string flutter.minSdkVersion
My gradle file (android/app/build.gradle) is the following:

...
    defaultConfig {
        applicationId "my.super.app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
...

@MustafaDev-shaikh
Copy link

@devaskim How to Solve.??

@devaskim
Copy link

I can only suggest quickfix, just replace flutter.minSdkVersion with 16 or greater.
Then run flutter pub run flutter_launcher_icons:main -f pubspec.yaml to generate icons.
Then replace back your integer with flutter.minSdkVersion and build and run your app.

@devaskim
Copy link

Here is more information about minSdkVersion

@ghost
Copy link
Author

ghost commented Mar 23, 2022

I can only suggest quickfix, just replace flutter.minSdkVersion with 16 or greater. Then run flutter pub run flutter_launcher_icons:main -f pubspec.yaml to generate icons. Then replace back your integer with flutter.minSdkVersion and build and run your app.

this fix is working fine

@Dancovich
Copy link

The issue in code is here. It is expected to be an integer but in my case it is a string flutter.minSdkVersion My gradle file (android/app/build.gradle) is the following:

...
    defaultConfig {
        applicationId "my.super.app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
...

I'd like to add that this code also doesn't differentiate between the variable minSdkVersion and any comment that happen to contain the word minSdkVersion.

So just commenting your old value and adding a new one temporarily setting it to an int value won't solve the issue. You have to remove any mentions of minSdkVersion except the one with an int value.

@fmattoso
Copy link

this fix is working fine for me. Tanks!

@LahaLuhem
Copy link

LahaLuhem commented Apr 7, 2022

I have an easy fix:

  1. Change Line 308 in Dart Packages/flutter_launcher_icons/android.dart:
    • previous: final String minSdk = line.replaceAll(RegExp(r'[^\d]'), '');
    • change to: final String minSdk = "21";
  2. Recompile the packages by running flutter clean, followed by flutter pub get again
  3. Run generating procedure again by flutter pub run flutter_launcher_icons:main

It just skips the parsing of the manifest file directly to get the minSDK version line.

@artificialphoton
Copy link

FIx:
Remove all instances of the word minSdkVersion in android/app/build.gradle &
Include minSdkVersion 21 (or your desired version) inside defaultConfig { } in android/app/build.gradle.

Cause:
This library looks for all instances of the word minSdkVersion in each line of android/app/build.gradle file and when it finds one it uses regular expression to remove everything except numbers. So even if there is a comment that contains the word minSdkVersion it will try to pull out the version number from there and results in an error if it doesn't find a number as it will try to parse an empty string to int.

@jiangliheng
Copy link

I have an easy fix:

  1. Change Line 308 in Dart Packages/flutter_launcher_icons/android.dart:

    • previous: final String minSdk = line.replaceAll(RegExp(r'[^\d]'), '');
    • change to: final String minSdk = "21";
  2. Recompile the packages by running flutter clean, followed by flutter pub get again

  3. Run generating procedure again by flutter pub run flutter_launcher_icons:main

It just skips the parsing of the manifest file directly to get the minSDK version line.

it work for me~

@Miamoto-Musashi
Copy link

if the fix is working how about release it? have this problem for days

@Dancovich
Copy link

if the fix is working how about release it? have this problem for days

These people are talking about workarounds you can do on your project. I don't think anyone fixed the actual plugin.

@cotwitch
Copy link

@Veseth2021
Copy link

Should use this forked package instead: https://pub.dev/packages/icons_launcher

@PhpCable
Copy link

PhpCable commented Jun 3, 2022

The issue in code is here. It is expected to be an integer but in my case it is a string flutter.minSdkVersion My gradle file (android/app/build.gradle) is the following:

...
    defaultConfig {
        applicationId "my.super.app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
...

This is the solution fix simple

@hbernalp
Copy link

3. flutter pub run flutter_launcher_icons:main

exelente amigo, esta fue la respuesta que me funciono.. gracias por el aporte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.