Hive: Weird Error when Upgrading to the Latest Hive_Generator

Created on 28 Jul 2020  路  3Comments  路  Source: hivedb/hive

Steps to Reproduce
Upgraded hive_generator: ^0.7.0+2 to hive_generator: ^0.7.1
Upgraded hive: ^1.4.1+1 to hive: ^1.4.2

Executed: flutter pub run build_runner watch --delete-conflicting-outputs

Pubspec
Previous Pubspec.yaml:

dependencies:
  hive: ^1.4.1+1
  hive_flutter:
     git:
       url: git://github.com/hivedb/hive/
       path: hive_flutter
dev_dependencies:
  hive_generator: ^0.7.0+2
dependency_overrides:
  dartx: ^0.3.0
  quiver: ^2.1.3

New Pubspec.yaml:

dependencies:
  hive: ^1.4.2
  hive_flutter: 0.3.1
dev_dependencies:
  hive_generator: ^0.7.1

Error when Running on hive_generator: ^0.7.1... flutter pub run build_runner watch --delete-conflicting-outputs:

[SEVERE] Failed to snapshot build script .dart_tool/build/entrypoint/build.dart.
This is likely caused by a misconfigured builder definition.
[SEVERE] ../../../flutter/.pub-cache/hosted/pub.dartlang.org/hive_generator-0.7.1/lib/src/type_adapter_generator.dart:60:76: 
Error: Getter not found: 'ENUM'.
check(element.kind == ElementKind.CLASS || element.kind == ElementKind.ENUM, 

Unsure what the error means or how to go about solving the issue.

Code Sample
Model:

@HiveType(typeId: 1)
class HiveExample extends HiveObject {
  @HiveField(0)
  List<int> numbers;
  @HiveField(1)
  List<String> words;
}

Main:

Hive.registerAdapter(HiveExampleAdapter());

Usage:

return HiveExample()
      ..numbers = Addnumbers
      ..words = Addwords;

Version

  • Platform: Linux
  • Flutter version: v1.17.5
  • Hive version: 1.4.2
  • Hive Generator: 0.7.1
problem

Most helpful comment

It seems that dart is having issues. I had to resolve the issue with the following pubspec.yaml:

dependencies:
  hive: ^1.4.2
  hive_flutter: ^0.3.1
dev_dependencies:
  hive_generator: ^0.7.1
  build_runner: 1.10.1
  build_resolvers: ^1.3.10

dependency_overrides:
  analyzer: 0.39.14

All 3 comments

The issue was caused by analyzer package. Please use 0.39.14 version.

dependency_overrides:
  analyzer: 0.39.14

Also note that latest version of analyzer (0.39.15) causes another weird issue (for all generators, not just hive).

It seems that dart is having issues. I had to resolve the issue with the following pubspec.yaml:

dependencies:
  hive: ^1.4.2
  hive_flutter: ^0.3.1
dev_dependencies:
  hive_generator: ^0.7.1
  build_runner: 1.10.1
  build_resolvers: ^1.3.10

dependency_overrides:
  analyzer: 0.39.14

I got the same problem. Remove dependency_overrides: analyzer: 0.39.14 work for me 馃挭

dependencies:
  hive: ^1.4.4+1
  hive_flutter: ^0.3.1
dev_dependencies:
  hive_generator: ^0.7.1
  build_runner: 1.10.1
  build_resolvers: ^1.3.10
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yaymalaga picture yaymalaga  路  4Comments

Hopheylalal picture Hopheylalal  路  4Comments

NourEldinShobier picture NourEldinShobier  路  3Comments

cachapa picture cachapa  路  4Comments

rupamking1 picture rupamking1  路  3Comments