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] Getting Unhandled Exception #360

Closed
santo-apps opened this issue Apr 22, 2022 · 6 comments · Fixed by #322
Closed

[BUG] Getting Unhandled Exception #360

santo-apps opened this issue Apr 22, 2022 · 6 comments · Fixed by #322

Comments

@santo-apps
Copy link

ℹ️ Info

Version: ^0.9.2

💬 Description

Command executed:
flutter pub run flutter_launcher_icons:main

Exception:
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:///Users/admin/Dev/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

We ask that you include your pubspec.yaml file as a common problem we have seen has been the pubspec.yaml file being incorrect

name: fansinc
description: A new Flutter project.

The following line prevents the package from being accidentally published to

pub.dev using flutter pub publish. This is preferred for private packages.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

The following defines the version and build number for your application.

A version number is three numbers separated by dots, like 1.2.43

followed by an optional build number separated by a +.

Both the version and the builder number may be overridden in flutter

build by specifying --build-name and --build-number, respectively.

In Android, build-name is used as versionName while build-number used as versionCode.

Read more about Android versioning at https://developer.android.com/studio/publish/versioning

In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.

Read more about iOS versioning at

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 1.0.0+1

environment:
sdk: ">=2.15.1 <3.1.0"

Dependencies specify other packages that your package needs in order to work.

To automatically upgrade your package dependencies to the latest versions

consider running flutter pub upgrade --major-versions. Alternatively,

dependencies can be manually updated by changing the version numbers below to

the latest version available on pub.dev. To see which dependencies have newer

versions available, run flutter pub outdated.

dependencies:
flutter:
sdk: flutter
provider: ^6.0.1
intl: ^0.17.0
http: ^0.13.3
shared_preferences: ^2.0.6
image_picker: ^0.8.1+1
cached_network_image: ^2.3.3
url_launcher: ^6.0.9
material_design_icons_flutter: ^5.0.6595

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_launcher_icons: ^0.9.2

dev_dependencies:
flutter_test:
sdk: flutter
#flutter_launcher_name: "^0.0.1"
flutter_app_name: ^0.1.0
flutter_staggered_grid_view: ^0.4.0

flutter_app_name:
name: "FansInc"

#flutter_launcher_name:
#name: "FansInc"

flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/images/aw1_logo.png"

The "flutter_lints" package below contains a set of recommended lints to

encourage good coding practices. The lint set provided by the package is

activated in the analysis_options.yaml file located at the root of your

package. See that file for information about deactivating specific lint

rules and activating additional ones.

flutter_lints: ^1.0.0

For information on the generic Dart part of this file, see the

following page: https://dart.dev/tools/pub/pubspec

The following section is specific to Flutter.

flutter:

The following line ensures that the Material Icons font is

included with your application, so that you can use the icons in

the material Icons class.

uses-material-design: true

To add assets to your application, add an assets section, like this:

assets:

  • assets/icons/tick.png
  • assets/images/image-loader.gif
  • assets/images/default.jpg
  • assets/images/aw1_logo.png
  • assets/images/google_logo.png
  • assets/images/coming_soon.jpg

An image asset can refer to one or more resolution-specific "variants", see

https://flutter.dev/assets-and-images/#resolution-aware.

For details regarding adding assets from package dependencies, see

https://flutter.dev/assets-and-images/#from-packages

To add custom fonts to your application, add a fonts section here,

in this "flutter" section. Each entry in this list should have a

"family" key with the font family name, and a "fonts" key with a

list giving the asset and other descriptors for the font. For

example:

fonts:
- family: ProximaNova
fonts:
- asset: assets/fonts/ProximaNova-Regular.otf

- asset: fonts/Schyler-Italic.ttf

style: italic

- family: Trajan Pro

fonts:

- asset: fonts/TrajanPro.ttf

- asset: fonts/TrajanPro_Bold.ttf

weight: 700

For details regarding fonts from package dependencies,

see https://flutter.dev/custom-fonts/#from-packages

@cotwitch
Copy link

@fbanyai
Copy link

fbanyai commented Apr 28, 2022

Hey!

I was having this same problem and found the solution. Since recent versions of Flutter the /android/app/build.gradle file have been using a new approach to control minSdkVersion and targetSdkVersion.

Ex:

.
.
.
def flutterMinSdkVersion = localProperties.getProperty('flutter.minSdkVersion')
if (flutterMinSdkVersion == null) {
    flutterMinSdkVersion = '21'
}

def flutterTargetSdkVersion = localProperties.getProperty('flutter.targetSdkVersion')
if (flutterTargetSdkVersion == null) {
    flutterTargetSdkVersion = '30'
}
.
.
.
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "name"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
.
.
.

It turns out that this package relies on the minSdkVersion substring while parsing this file in order to generate the icons. And since the updated version has this subtring in many places, it crashes.

The solution was to revert to the old approach, without the localProperties.getProperty snipet and hard-coding the numbers in the minSdkVersion and targetSdkVersion params inside the defaultConfig node.

So, in order to be able to run the flutter pub run flutter_launcher_icons:main again, you have to edit the following parts inside your /android/app/build.gradle file:

REMOVE (not just comment) the block below :

def flutterMinSdkVersion = localProperties.getProperty('flutter.minSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '21'
}

def flutterTargetSdkVersion = localProperties.getProperty('flutter.targetSdkVersion')
if (flutterTargetSdkVersion == null) {
    flutterTargetSdkVersion = '30'
}

USE NUMBERS as the values for minSdkVersion and targetSdkVersion params in following block:

defaultConfig {
    applicationId "name"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

The number above are the versions I use for my project. Please be free to update them to your desired version.

Finally, you can re-run the flutter pub run flutter_launcher_icons:main command. If needed, feel free to revert the suggested tweak after generating the icons.

@jlyonsmith
Copy link

You can also use one of the many fixed forked versions to get around the problem. For example:

dev_dependencies:
  flutter_launcher_icons:
    git:
      url: [email protected]:RatakondalaArun/flutter_launcher_icons.git
      ref: fix/flutter-v2.8.0-support-321

This checks the local.properties file for a definition of minSdkVersion which you should set to 26 or higher to support Android adaptive icons.

@theharshguptaflutter
Copy link

flutter pub run flutter_launcher_icons:main -f pubspec.yaml
════════════════════════════════════════════
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.1/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

can anyone help me I'm also getting same error and i also changed my minsdk 21 tergetsdk 29 but not working

@jlyonsmith
Copy link

flutter pub run flutter_launcher_icons:main -f pubspec.yaml ════════════════════════════════════════════ 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.1/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

can anyone help me I'm also getting same error and i also changed my minsdk 21 tergetsdk 29 but not working

@theharshguptaflutter this is exactly the problem I was having and for which I described a fix for above. Have you tried using a forked version?

@Veseth2021
Copy link

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

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.

6 participants