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

Failed to precompile build script .dart_tool/build/entrypoint/build.dart #1203

Open
celvinren opened this issue Jan 6, 2023 · 2 comments
Open

Comments

@celvinren
Copy link

flutter pub run build_runner build --delete-conflicting-outputs
I ran the above cmd to generate .g file 1 months ago, but now it reporting this error message.
Try to do flutter clean and pub get again, but it doesn't resolve the issue.

Can anyone help me to fix this issue?

Thanks

`[INFO] Generating build script completed, took 351ms
[WARNING] /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/serializer_source_library.dart:125:43: Error: The getter 'element' isn't defined for the class 'DartType'.

  • 'DartType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    SerializerSourceClass(type!.element as InterfaceElement)));
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/dart_types.dart:26:31: Error: The getter 'element' isn't defined for the class 'DartType'.
  • 'DartType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    ValueSourceClass(type.element as ClassElement).settings.instantiable;
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/dart_types.dart:31:12: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    type.element.allSupertypes
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/dart_types.dart:75:25: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    return dartType.element.name + suffix;
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/dart_types.dart:80:28: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    return '${dartType.element.name}<$typeArgumentsStr>$suffix';
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/dart_types.dart:83:23: Error: The getter 'element' isn't defined for the class 'TypeParameterType'.
  • 'TypeParameterType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    return dartType.element.name + suffix;
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:78:45: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .any((interfaceType) => interfaceType.element.name == 'Built');
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:96:29: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    ...element.supertype!.element.allSupertypes
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:219:49: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .where((interfaceType) => interfaceType.element.name == 'Builder')
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:319:57: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .where((interface) => needsBuiltValue(interface.element))
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:328:55: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .where((interface) => needsBuiltValue(interface.element))
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:367:24: Error: The getter 'enclosingElement' isn't defined for the class 'MethodElement'.
  • 'MethodElement' is from 'package:analyzer/dart/element/element.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/element.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'enclosingElement'.
    var clazz = method.enclosingElement;
    ^^^^^^^^^^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:379:50: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    (interfaceType) => interfaceType.element.name == 'Built') ||
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/value_source_class.dart:1080:48: Error: The getter 'element' isn't defined for the class 'DartType'.
  • 'DartType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    field.element.getter!.returnType.element!.displayName;
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/serializer_source_class.dart:146:31: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .map((type) => type.element.name)
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/serializer_source_class.dart:155:31: Error: The getter 'element' isn't defined for the class 'InterfaceType'.
  • 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    .map((type) => type.element.name)
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/serializer_source_class.dart:196:42: Error: The getter 'element' isn't defined for the class 'DartType'.
  • 'DartType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    final fieldTypeElement = fieldType.element;
    ^^^^^^^
    /Users/calvin/.pub-cache/hosted/pub.dartlang.org/built_value_generator-8.4.2/lib/src/serializer_source_class.dart:205:36: Error: The getter 'element' isn't defined for the class 'DartType'.
  • 'DartType' is from 'package:analyzer/dart/element/type.dart' ('/Users/calvin/.pub-cache/hosted/pub.dartlang.org/analyzer-5.1.0/lib/dart/element/type.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'element'.
    final typeElement = type.element;
    ^^^^^^^
    [INFO] Precompiling build script... completed, took 809ms
    [SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.
    This is likely caused by a misconfigured builder definition.`
@dave26199
Copy link

This could relate to the analyzer version ... could you post the output of "dart pub get" and "dart pub upgrade"? Possibly, upgrade will fix it.

@Petri-Oosthuizen
Copy link

I encountered the same error. Overriding the analyzer works in the meantime.

dependency_overrides:
  analyzer: 5.2.0

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

No branches or pull requests

3 participants