flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[tool_crash] FormatException: FormatException: Unexpected character (at line 66, character 3) ']' when building ipa

Open sssolinjie opened this issue 1 year ago • 8 comments

Flutter crash report. Please report a bug at https://github.com/flutter/flutter/issues.

command

flutter build ipa

exception

FormatException: FormatException: Unexpected character (at line 66, character 3) ], ^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1376:5)
#1      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:888:13)
#2      _parseJson (dart:convert-patch/convert_patch.dart:35:10)
#3      JsonDecoder.convert (dart:convert/json.dart:610:36)
#4      JsonCodec.decode (dart:convert/json.dart:216:41)
#5      BuildIOSArchiveCommand._parseImageAssetContentsJson (package:flutter_tools/src/commands/build_ios.dart:184:48)
#6      BuildIOSArchiveCommand._validateLaunchImageAssetsAfterArchive (package:flutter_tools/src/commands/build_ios.dart:352:60)
<asynchronous suspension>
#7      BuildIOSArchiveCommand.runCommand (package:flutter_tools/src/commands/build_ios.dart:434:49)
<asynchronous suspension>
#8      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1389:27)
<asynchronous suspension>
#9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#10     CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#11     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:355:9)
<asynchronous suspension>
#12     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#13     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:295:5)
<asynchronous suspension>
#14     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:119:9)
<asynchronous suspension>
#15     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#16     main (package:flutter_tools/executable.dart:90:3)
<asynchronous suspension>

flutter doctor

[32m[✓][39m Flutter (Channel stable, 3.19.2, on macOS 14.4.1 23E224 darwin-arm64, locale zh-Hans-CN)
    [32m•[39m Flutter version 3.19.2 on channel stable at /Users/linbingwu/.fvm/versions/3.19.2
    [32m•[39m Upstream repository https://github.com/flutter/flutter.git
    [32m•[39m Framework revision 7482962148 (5 周前), 2024-02-27 16:51:22 -0500
    [32m•[39m Engine revision 04817c99c9
    [32m•[39m Dart version 3.3.0
    [32m•[39m DevTools version 2.31.1
    [32m•[39m Pub download mirror https://pub.flutter-io.cn
    [32m•[39m Flutter download mirror https://storage.flutter-io.cn

[32m[✓][39m Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    [32m•[39m Android SDK at /Users/linbingwu/Library/Android/sdk
    [32m•[39m Platform android-34, build-tools 33.0.2
    [32m•[39m ANDROID_HOME = /Users/linbingwu/Library/Android/sdk
    [32m•[39m Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    [32m•[39m Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    [32m•[39m All Android licenses accepted.

[32m[✓][39m Xcode - develop for iOS and macOS (Xcode 15.3)
    [32m•[39m Xcode at /Applications/Xcode.app/Contents/Developer
    [32m•[39m Build 15E204a
    [32m•[39m CocoaPods version 1.15.2

[32m[✓][39m Chrome - develop for the web
    [32m•[39m Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[32m[✓][39m Android Studio (version 2022.3)
    [32m•[39m Android Studio at /Applications/Android Studio.app/Contents
    [32m•[39m Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    [32m•[39m Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    [32m•[39m Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[32m[✓][39m VS Code (version 1.87.2)
    [32m•[39m VS Code at /Applications/Visual Studio Code.app/Contents
    [32m•[39m Flutter extension version 3.86.0

[32m[✓][39m Connected device (4 available)
    [32m•[39m 蔡平的iPhone (mobile)    • 00008030-001E246E3A84802E • ios            • iOS 17.4 21E219
    [32m•[39m iPhonelinjie (mobile) • 00008020-000C69EC3CD9002E • ios            • iOS 17.4.1 21E236
    [32m•[39m macOS (desktop)       • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    [32m•[39m Chrome (web)          • chrome                    • web-javascript • Google Chrome 123.0.6312.87

[32m[✓][39m Network resources
    [32m•[39m All expected network resources are available.

[32m•[39m No issues found!

sssolinjie avatar Apr 03 '24 06:04 sssolinjie

flutter_02.log

sssolinjie avatar Apr 03 '24 06:04 sssolinjie

Hi @sssolinjie, do you get this issue with the counter app? If not could you provide a minimal reproducible code sample (preferably in a repo that we can clone) so that we can investigate this issue?

Thank you

danagbemava-nc avatar Apr 03 '24 09:04 danagbemava-nc

Hi @sssolinjie, do you get this issue with the counter app? If not could you provide a minimal reproducible code sample (preferably in a repo that we can clone) so that we can investigate this issue?

Thank you

https://github.com/sssolinjie/flutter_build_ios_demo.git

sssolinjie avatar Apr 07 '24 02:04 sssolinjie

@danagbemava-nc

sssolinjie avatar Apr 07 '24 08:04 sssolinjie

Reproducible using the repository in https://github.com/flutter/flutter/issues/146184#issuecomment-2041280426

I tested on a project with the default assets and the ipa was built successfully but this project which has custom launch assets fails.

Running flutter build ios on the same project worked without any issues.

flutter_03.log

Labeling for further investigation

flutter doctor -v
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.3.1 23D60 darwin-arm64, locale en-GB)
    • Flutter version 3.19.5 on channel stable at /Users/nexus/dev/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (11 days ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 77.2.2
    • Dart plugin version 232.10286

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (4 available)
    • Nexus (mobile)       • 00008020-001875E83A38002E • ios            • iOS 17.4.1 21E236
    • Dean’s iPad (mobile) • 00008103-000825C811E3401E • ios            • iOS 17.4.1 21E236
    • macOS (desktop)      • macos                     • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)         • chrome                    • web-javascript • Google Chrome 123.0.6312.107

[✓] Network resources
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.22.0-5.0.pre.55, on macOS 14.3.1 23D60 darwin-arm64, locale en-GB)
    • Flutter version 3.22.0-5.0.pre.55 on channel master at /Users/nexus/dev/sdks/flutters
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutters. Consider adding /Users/nexus/dev/sdks/flutters/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ddf79b755d (9 hours ago), 2024-04-07 18:34:24 -0400
    • Engine revision c10e950c66
    • Dart version 3.5.0 (build 3.5.0-18.0.dev)
    • DevTools version 2.34.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 77.2.2
    • Dart plugin version 232.10286

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.86.0

[✓] Connected device (5 available)
    • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.4.1 21E236
    • Dean’s iPad (mobile)            • 00008103-000825C811E3401E • ios            • iOS 17.4.1 21E236
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 123.0.6312.107

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

danagbemava-nc avatar Apr 08 '24 07:04 danagbemava-nc

Based on the crash log, looks like the Contents.json under launch image is corrupted. Did you accidentally edit this file?

hellohuanlin avatar Apr 08 '24 20:04 hellohuanlin

Here you have an extra comma, which makes the JSON invalid:

https://github.com/sssolinjie/flutter_build_ios_demo/blob/62f06c654e3e431d062263bb49206b692b588a20/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json#L65

Closing as resolved, but feel free to re-open otherwise.

hellohuanlin avatar Apr 08 '24 21:04 hellohuanlin

Reopening:

  1. If the tool crashed here, it should give a hint about what file is corrupted.
  2. The tool ideally shouldn't crash on a user-editable app file. This should catch the FormatException and give the user a hint about how to fix it. For example: https://github.com/flutter/flutter/blob/74b65d4e4c6190fedd76e02c83196688ac149467/packages/flutter_tools/lib/src/base/deferred_component.dart#L191-L195

jmagman avatar Apr 10 '24 18:04 jmagman