Build: can not run build_runner in flutter v1.20.0

Created on 4 Sep 2020  Â·  6Comments  Â·  Source: dart-lang/build

Hello team,

Thank you for making great Flutter framework.

I am trying app with Gitlab pipeline and have 1 issue with flutter v1.20.0 that I can not run this command

flutter pub run build_runner build

I got error message like:

Error: The getter 'externalKeyword' isn't defined for the class 'FieldDeclaration'.

I also try some ways like https://github.com/flutter/flutter/issues/62996 and https://github.com/flutter/flutter/issues/56779
But it sometime happens on my local environment, and always happens on gitlab pipepine

This is my yaml configuration file:
```image: cirrusci/flutter:1.20.0
stages:

  • z
  • t

before_script:

  • flutter clean
  • flutter pub get
  • flutter pub run build_runner build
My pubspec.yaml

environment:
sdk: ">=2.2.2 <3.0.0"

dependencies:
flutter:
sdk: flutter
package_info: ^0.4.0+17
cupertino_icons: ^0.1.2
json_annotation: ^3.0.0
flutter_svg: ^0.18.0
charts_flutter: ^0.8.1
http: ^0.12.0+2
redux:
flutter_redux:
mockito:
json_serializable: ^3.2.3
flutter_auth0: ^0.5.0
shared_preferences: ^0.5.6+3
google_maps_flutter: ^0.5.27+1
video_player: ^0.10.11+1
chewie: ^0.9.10
hive: ^1.4.1+1
hive_flutter: ^0.3.0+2
path_provider: ^1.6.11
intl: ^0.16.0
flutter_platform_widgets: ^0.60.1

dev_dependencies:
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
test: any
hive_generator: ^0.7.0+2
build_runner:

dependency_overrides:
analyzer: 0.39.14

My pubspec.lock

build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.1"

Here is more detailed info:
<details>
  <summary>Logs</summary>


PS D:xx> flutter pub run build_runner build
Precompiling executable...
Failed to precompile build_runner:build_runner:
/D:/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.7/lib/src/source_visitor.dart:1428:21: Error: The getter 'externalKeyword' isn't defined for the class 'FieldDeclaration'.

  • 'FieldDeclaration' is from 'package:analyzer/dart/ast/ast.dart' ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.14/lib/dart/ast/ast.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'externalKeyword'.
    modifier(node.externalKeyword);
    ^^^^^^^^^^^^^^^
    /D:/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.7/lib/src/source_visitor.dart:1430:21: Error: The getter 'abstractKeyword' isn't defined for the class 'FieldDeclaration'.
  • 'FieldDeclaration' is from 'package:analyzer/dart/ast/ast.dart' ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.14/lib/dart/ast/ast.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'abstractKeyword'.
    modifier(node.abstractKeyword);
    ^^^^^^^^^^^^^^^
    /D:/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.7/lib/src/source_visitor.dart:2618:21: Error: The getter 'externalKeyword' isn't defined for the class 'TopLevelVariableDeclaration'.
  • 'TopLevelVariableDeclaration' is from 'package:analyzer/dart/ast/ast.dart' ('/D:/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.39.14/lib/dart/ast/ast.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'externalKeyword'.
    modifier(node.externalKeyword);
    ^^^^^^^^^^^^^^^
    pub finished with exit code 1
<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

dart --version
Dart SDK version: 2.9.0 (stable) (Fri Jul 31 10:59:48 2020 +0200) on "windows_x64"

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

PS D:xx> flutter doctor -v
[√] Flutter (Channel unknown, 1.20.0, on Microsoft Windows [Version 10.0.18362.720], locale en-US)
• Flutter version 1.20.0 at D:flutter
• Framework revision 840c9205b3 (4 weeks ago), 2020-08-04 20:55:12 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:AndroidSdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = D:AndroidSdk
• Java binary at: C:Program FilesAndroidAndroid Studiojrebinjava
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Android Studio (version 4.0)
• Android Studio at C:Program FilesAndroidAndroid Studio
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code, 64-bit edition (version 1.44.1)
• VS Code at C:Program FilesMicrosoft VS Code
• Flutter extension version 3.12.2

[!] Connected device
! No devices available

! Doctor found issues in 1 category.
```

Thank you

Clone from https://github.com/flutter/flutter/issues/65249

Most helpful comment

I ran into the same issue, but could resolve it by removing the override on analyzer.

All 6 comments

The problem is most likely due to the dependency override on analyzer, can you try removing that?

I have the same problem ...

I remove path: 1.7.0 from dependencies and use built_value: ^6.7.1 and works fine.

I ran into the same issue, but could resolve it by removing the override on analyzer.

I ran into the same issue, but could resolve it by removing the override on analyzer.

This works for me too. You have to remove dependency_overrides: analyzer: 0.39.14 entirely.

Closing this as removing the analyzer appears to resolve things as expected

Was this page helpful?
0 / 5 - 0 ratings