Jaguar-dart/jaguar_serializer

Compiler error when building Gradle --release version / Flutter, Android

Closed this issue · 11 comments

Debug builds seem to work just fine. Can someone point me to the right direction for fixing this?

Error log:

$ flutter run --release -d nexus
Initializing gradle...                                       0.8s
Resolving dependencies...                                    1.3s
Launching lib/main.dart on Nexus 5X in release mode...
Running 'gradlew assembleRelease'...
compiler message: Unhandled exception:
Missing canonical name for Reference to jaguar_serializer.annotations::FieldFormat::none
#0      BinaryPrinter.writeReference (package:kernel/binary/ast_to_binary.dart:509)
#1      BinaryPrinter.visitStaticGet (package:kernel/binary/ast_to_binary.dart:1058)
#2      StaticGet.accept (package:kernel/ast.dart:2543)
#3      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#4      LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#5      BinaryPrinter.writeOptionalNode (package:kernel/binary/ast_to_binary.dart:237)
#6      BinaryPrinter.writeVariableDeclaration (package:kernel/binary/ast_to_binary.dart:1583)
#7      List.forEach (dart:core-patch/dart:core/growable_array.dart:274)
#8      BinaryPrinter.writeList (package:kernel/binary/ast_to_binary.dart:213)
#9      BinaryPrinter.writeVariableDeclarationList (package:kernel/binary/ast_to_binary.dart:1590)
#10     BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:948)
#11     FunctionNode.accept (package:kernel/ast.dart:1991)
#12     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#13     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#14     BinaryPrinter.visitConstructor (package:kernel/binary/ast_to_binary.dart:780)
#15     Constructor.accept (package:kernel/ast.dart:1273)
#16     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#17     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#18     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221)
#19     BinaryPrinter.visitClass (package:kernel/binary/ast_to_binary.dart:743)
#20     Class.accept (package:kernel/ast.dart:859)
#21     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#22     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#23     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221)
#24     BinaryPrinter.visitLibrary (package:kernel/binary/ast_to_binary.dart:597)
#25     Library.accept (package:kernel/ast.dart:409)
#26     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#27     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#28     List.forEach (dart:core-patch/dart:core/growable_array.dart:274)
#29     BinaryPrinter.writeList (package:kernel/binary/ast_to_binary.dart:213)
#30     LimitedBinaryPrinter.writeLibraries (package:kernel/binary/limited_ast_to_binary.dart:49)
#31     BinaryPrinter.writeComponentFile (package:kernel/binary/ast_to_binary.dart:309)
#32     FrontendCompiler.compile (package:vm/frontend_server.dart:287)
<asynchronous suspension>
#33     _FlutterFrontendCompiler.compile (package:frontend_server/server.dart:29)
<asynchronous suspension>
#34     starter (package:frontend_server/server.dart:107)
<asynchronous suspension>
#35     main (file:///E:/b/build/slave/Windows_Engine/build/src/flutter/frontend_server/bin/starter.dart:6)
#36     _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:277)
#37     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)

Compiler terminated unexpectedly.

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\Vu\SDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 389

* What went wrong:
Execution failed for task ':app:flutterBuildRelease'.
> Process 'command 'C:\Users\Vu\SDK\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
Gradle build failed: 1
$ flutter --version
Flutter 0.3.1-pre.25 • channel master • https://github.com/flutter/flutter.git
Framework • revision 9a0b562524 (23 hours ago) • 2018-04-17 16:57:47 -0700
Engine • revision 0c09bf03d1
Tools • Dart 2.0.0-dev.48.0.flutter-f76dad0adc

I'm currently having the same issue. The build works just fine with the --no-preview-dart-2 flag added. Also, as @veltall mentioned, the debug version works fine as well (even with Dart 2).

@VriesDeRick Thanks for the tip on the flag. I was going to write my own custom serializer if the bug isn't fixed by the time I need to ship the prototype. 👌

Is there any way to use your fix now (like straight from github) ?

When I configure my dependencies like so:

  jaguar_serializer:
    git:
      url: git://github.com/Jaguar-dart/jaguar_serializer.git
      path: jaguar_serializer
      ref: 1.0.0-dev
  build_runner: ^0.8.0
  jaguar_serializer_cli:
    git:
        url: git://github.com/Jaguar-dart/jaguar_serializer.git
        path: jaguar_serializer_cli
        ref: 1.0.0-dev

I get:

Running "flutter packages get" in con_flutter...
Because every version of jaguar_serializer_cli from git depends on jaguar_serializer from hosted
  and con_flutter depends on jaguar_serializer from git, jaguar_serializer_cli from git is
  forbidden.
So, because con_flutter depends on jaguar_serializer_cli from git, version solving failed.
pub get failed (1)

Could you guys test it and let us know, if this fixes your problems?

It fixes the earlier error, but I'm still stuck on another error.
I'm not quite sure if this is caused by the serializer, or by another package.
I've tried building on both the second and the third beta, and regenerated the serializers every time.
Again, the error only occurs in release mode with Dart 2, which makes sense, given it's a compiler error:

compiler message: Unhandled exception:
NoSuchMethodError: The method '<' was called on null.
Receiver: null
Tried calling: <(128)
#0      Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
#1      BinaryPrinter.writeUInt30 (package:kernel/binary/ast_to_binary.dart:78)
#2      BinaryPrinter.visitTypeParameterType (package:kernel/binary/ast_to_binary.dart:1697)
#3      TypeParameterType.accept (package:kernel/ast.dart:5183)
#4      BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#5      LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#6      BinaryPrinter.writeVariableDeclaration (package:kernel/binary/ast_to_binary.dart:1590)
#7      List.forEach (dart:core-patch/dart:core/growable_array.dart:274)
#8      BinaryPrinter.writeList (package:kernel/binary/ast_to_binary.dart:213)
#9      BinaryPrinter.writeVariableDeclarationList (package:kernel/binary/ast_to_binary.dart:1598)
#10     BinaryPrinter.visitFunctionNode (package:kernel/binary/ast_to_binary.dart:950)
#11     FunctionNode.accept (package:kernel/ast.dart:1994)
#12     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#13     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#14     BinaryPrinter.visitConstructor (package:kernel/binary/ast_to_binary.dart:782)
#15     Constructor.accept (package:kernel/ast.dart:1276)
#16     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#17     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#18     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221)
#19     BinaryPrinter.visitClass (package:kernel/binary/ast_to_binary.dart:745)
#20     Class.accept (package:kernel/ast.dart:862)
#21     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#22     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#23     BinaryPrinter.writeNodeList (package:kernel/binary/ast_to_binary.dart:221)
#24     BinaryPrinter.visitLibrary (package:kernel/binary/ast_to_binary.dart:597)
#25     Library.accept (package:kernel/ast.dart:409)
#26     BinaryPrinter.writeNode (package:kernel/binary/ast_to_binary.dart:229)
#27     LimitedBinaryPrinter.writeNode (package:kernel/binary/limited_ast_to_binary.dart:55)
#28     List.forEach (dart:core-patch/dart:core/growable_array.dart:274)
#29     BinaryPrinter.writeList (package:kernel/binary/ast_to_binary.dart:213)
#30     LimitedBinaryPrinter.writeLibraries (package:kernel/binary/limited_ast_to_binary.dart:49)
#31     BinaryPrinter.writeComponentFile (package:kernel/binary/ast_to_binary.dart:309)
#32     FrontendCompiler.compile (package:vm/frontend_server.dart:276)
<asynchronous suspension>
#33     _FlutterFrontendCompiler.compile (package:frontend_server/server.dart:29)
<asynchronous suspension>
#34     starter (package:frontend_server/server.dart:107)
<asynchronous suspension>
#35     main (file:///b/build/slave/Linux_Engine/build/src/flutter/frontend_server/bin/starter.dart:6)
#36     _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:277)
#37     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)

I don't know if this sounds somewhat familiar to you, but if you happen to know what causes it, please let me know.

hard to tell :/
I don't see any related jaguar_serializer stuff in the stacktrace.

I recommend you to create an issue on the flutter repo and link this one

Someone else reported it as well, and by now a fix has been rolled into the master channel of Flutter.

Thanks to you both for looking into the issue! Using the latest master, everything compiles well, including the serializers.

👍