Skip to content

Build fails after upgrading Realm to 20.2.0 due to analyzer_plugin type conflicts #1872

@gauravkatkar4242

Description

@gauravkatkar4242

What happened?

After upgrading the Realm Flutter package, our project fails to build with the following errors related to analyzer_plugin and type conflicts between Element and Element2. It seems like some dependencies are incompatible with the current analyzer version.

Repro steps

Upgrade Realm in pubspec.yaml to the latest version.

Run flutter pub get.

Run flutter pub run build_runner build (or any build using build_runner).

Version

3.29.3

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

Code snippets

No response

Stacktrace of the exception/crash you're getting

Building package executable... (5.5s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 750ms
[WARNING] ../../../.pub-cache/hosted/pub.dev/analyzer_plugin-0.12.0/lib/src/utilities/change_builder/change_builder_dart.dart:2133:32: Error: The argument type 'Element' can't be assigned to the parameter type 'Element2'.
 - 'Element' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element.dart').
 - 'Element2' is from 'package:analyzer/dart/element/element2.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element2.dart').
            .publiclyExporting(element, resultCache: resultCache) ??
                               ^
../../../.pub-cache/hosted/pub.dev/analyzer_plugin-0.12.0/lib/src/utilities/change_builder/change_builder_dart.dart:2133:54: Error: The argument type 'Map<Element, LibraryElement?>?' can't be assigned to the parameter type 'Map<Element2, LibraryElement2?>?'.
 - 'Map' is from 'dart:core'.
 - 'Element' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element.dart').
 - 'LibraryElement' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element.dart').
 - 'Element2' is from 'package:analyzer/dart/element/element2.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element2.dart').
 - 'LibraryElement2' is from 'package:analyzer/dart/element/element2.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element2.dart').
            .publiclyExporting(element, resultCache: resultCache) ??
                                                     ^
../../../.pub-cache/hosted/pub.dev/analyzer_plugin-0.12.0/lib/src/utilities/change_builder/change_builder_dart.dart:2137:40: Error: The getter 'source' isn't defined for the class 'Object'.
 - 'Object' is from 'dart:core'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'source'.
    var uriToImport = libraryToImport?.source.uri;
                                       ^^^^^^
../../../.pub-cache/hosted/pub.dev/analyzer_plugin-0.12.0/lib/src/utilities/change_builder/change_builder_dart.dart:2150:58: Error: The argument type 'Object?' can't be assigned to the parameter type 'LibraryElement?'.
 - 'Object' is from 'dart:core'.
 - 'LibraryElement' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/dart/element/element.dart').
      _removeUnnecessaryPendingElementImports(newImport, libraryToImport);
                                                         ^
../../../.pub-cache/hosted/pub.dev/analyzer_plugin-0.12.0/lib/src/utilities/change_builder/change_builder_dart.dart:2182:14: Error: The method 'publiclyExporting2' isn't defined for the class 'TopLevelDeclarations'.
 - 'TopLevelDeclarations' is from 'package:analyzer/src/services/top_level_declarations.dart' ('../../../.pub-cache/hosted/pub.dev/analyzer-7.6.0/lib/src/services/top_level_declarations.dart').
Try correcting the name to the name of an existing method, or defining a method named 'publiclyExporting2'.
            .publiclyExporting2(element, resultCache: resultCache) ??
             ^^^^^^^^^^^^^^^^^^
[INFO] Precompiling build script... completed, took 8.2s
[SEVERE] Failed to precompile build script .dart_tool/build/entrypoint/build.dart.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions