Build: Running Json Serializable through VSCode (flutter) fails all of the sudden.

Created on 16 Jun 2020  Â·  2Comments  Â·  Source: dart-lang/build

Dart: Dart VM version: 2.9.0-14.1.beta (beta) (Tue Jun 9 10:52:57 2020 +0200) on "windows_x64"
Json Serializable 3.3.0
Flutter 1.19.0-4.1.pre • channel beta
Framework • revision f994b76974 (6 days ago) • 2020-06-09 15:53:13 -0700
Engine • revision 9a28c3bcf4
Tools • Dart 2.9.0 (build 2.9.0-14.1.beta)


Attempted to generate json mapping for

import 'package:json_annotation/json_annotation.dart';

part 'phone.g.dart';

@JsonSerializable(explicitToJson: true)
class Phone {
  String phone;
  String carrier;
  bool verified;
  bool has;

  Phone(this.phone);

  factory Phone.fromJson(Map<String, dynamic> json) => _$PhoneFromJson(json);

  Map<String, dynamic> toJson() => _$PhoneToJson(this);
}

Verbose Logs

C:\xxxxxxxxxxxx>flutter pub run build_runner build --delete-conflicting-outputs -v
[INFO] Generating build script...
[INFO] Generating build script completed, took 298ms



You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues


NoSuchMethodError: Closure call with mismatched arguments: function 'MutablePackageTree.allPackages'
Receiver: Closure: (_SyncIterator<Package>) => bool
Tried calling: MutablePackageTree.allPackages()
Found: MutablePackageTree.allPackages(_SyncIterator<Package>) => bool
dart:core                                                              _SyncIterable.iterator
package:package_config/src/package_config_impl.dart 26:36              new SimplePackageConfig
package:package_config/src/package_config_json.dart 213:10             parsePackageConfigJson
package:package_config/src/package_config_json.dart 45:10              parsePackageConfigBytes
package:package_config/src/package_config_io.dart 117:10               readPackageConfigJsonFile
package:package_config/src/discovery.dart 109:18                       findPackagConfigInDirectory
package:package_config/src/discovery.dart 44:31                        findPackageConfig
package:package_config/package_config.dart 114:5                       findPackageConfig
package:build_runner_core/src/package_graph/package_graph.dart 74:15   PackageGraph.forPath
package:build_runner_core/src/package_graph/package_graph.dart 110:20  PackageGraph.forThisPackage
package:build_runner/src/entrypoint/run.dart 22:64                     run
.dart_tool\build\entrypoint\build.dart 26:22                           main

pub finished with exit code 1

#0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:362:7)
<asynchronous suspension>
#2      PackagesForwardCommand.runCommand (package:flutter_tools/src/commands/packages.dart:239:15)
#3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:797:18)
#4      _rootRunUnary (dart:async/zone.dart:1198:47)
#5      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#6      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#9      Future._completeWithValue (dart:async/future_impl.dart:529:5)
#10     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#11     _rootRun (dart:async/zone.dart:1190:13)
#12     _CustomZone.run (dart:async/zone.dart:1093:19)
#13     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#14     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#15     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#16     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#17     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#18     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

Additional Information

  • There are over 50 generated files i frequently run this tool and it usually works like a charm. I've isolated this single file, after failing to generate it alongside all the other generated files to no avail.
  • This tool was working 48 hours ago, and I don't recall any dart or flutter updates
  • Using this through VSCode, however i've tried running it through commandline, same issue.
  • Removing the remove-conflicting-outputs results in the same error

Is there an issue with my pubspec? That's the only thing I can really take from the above error. Any help would be appreciated.

Most helpful comment

I found the solution, run :flutter clean and flutter pub get
Now it's work perfectly

All 2 comments

I found the solution, run :flutter clean and flutter pub get
Now it's work perfectly

There was an sdk issue where old snapshots would fail in a different way than they used to and we didn't catch it, thus running an old snapshot which manifested in this weird issue. But yes simply doing a clean is the right solution, that deletes the bad snapshot.

Was this page helpful?
0 / 5 - 0 ratings