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

[hive_generator] Error when running #63

Closed
SergeShkurko opened this issue Oct 1, 2019 · 4 comments
Closed

[hive_generator] Error when running #63

SergeShkurko opened this issue Oct 1, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@SergeShkurko
Copy link
Contributor

SergeShkurko commented Oct 1, 2019

Steps to Reproduce
When run $ flutter pub run build_runner build in project with hive
i getting error:

[INFO] Generating build script...
[INFO] Generating build script completed, took 287ms

[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 10.4s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 780ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Deleting 1 declared outputs which already existed on disk.
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms

[INFO] Running build...
[SEVERE] hive_generator:hive_generator on test/module_digest_test.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/bloc/digest/digest_event.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/bloc/digest/digest_state.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/bloc/digest_detail/digest_detail_state.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/bloc/digest_detail/digest_detail_event.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/data/models/responses/digest_detail.dart:

Invalid argument(s): Path must be absolute : dart:core
[SEVERE] hive_generator:hive_generator on lib/src/data/models/responses/digest.dart:

Invalid argument(s): Path must be absolute : dart:core


You have hit a bug in build_runner
Please file an issue with reproduction steps at https://github.com/dart-lang/build/issues


NoSuchMethodError: The getter 'references' was called on null.
Receiver: null
Tried calling: references
dart:core                                                         Object.noSuchMethod
package:analyzer/src/summary2/linked_bundle_context.dart 22:47    new LinkedBundleContext
package:analyzer/src/dart/analysis/library_context.dart 407:11    LibraryContext._createElementFactory    
package:analyzer/src/dart/analysis/library_context.dart 94:7      new LibraryContext
package:analyzer/src/dart/analysis/driver.dart 1439:29            AnalysisDriver._createLibraryContext    
package:analyzer/src/dart/analysis/driver.dart 1380:28            AnalysisDriver._computeUnitElement.<fn> 
package:analyzer/src/dart/analysis/performance_logger.dart 34:15  PerformanceLog.run
package:analyzer/src/dart/analysis/driver.dart 1378:20            AnalysisDriver._computeUnitElement      
package:analyzer/src/dart/analysis/driver.dart 997:34             AnalysisDriver.performWork
package:analyzer/src/dart/analysis/driver.dart 1931:24            AnalysisDriverScheduler._run
package:analyzer/src/dart/analysis/driver.dart 1865:5             AnalysisDriverScheduler.start
package:build_resolvers/src/analysis_driver.dart 54:13            analysisDriver
package:build_resolvers/src/resolver.dart 138:18                  new AnalyzerResolvers
package:build_runner_core/src/generate/options.dart 192:19        BuildOptions.create
package:build_runner/src/generate/build.dart 85:36                build
package:build_runner/src/entrypoint/build.dart 28:24              BuildCommand.run
package:args/command_runner.dart 197:27                           CommandRunner.runCommand
package:args/command_runner.dart 112:25                           CommandRunner.run.<fn>
dart:async                                                        new Future.sync
package:args/command_runner.dart 112:14                           CommandRunner.run
package:build_runner/src/entrypoint/run.dart 24:31                run
.dart_tool\build\entrypoint\build.dart 22:22                      main

Code sample

import 'package:hive/hive.dart';

part 'digest_cache.g.dart';

@HiveType()
class DigestCache {
  DigestCache({
    this.readingProgress,
    this.updateDate,
  });

  @HiveField(0)
  int readingProgress;
  @HiveField(1)
  DateTime updateDate;
}

Version

  • Flutter version: [1.9.1+hotfix.2]
  • Hive version: [1.0.0]
  • Hive generator version: [0.5.2]
@SergeShkurko SergeShkurko added the bug Something isn't working label Oct 1, 2019
@simc
Copy link
Member

simc commented Oct 1, 2019

This is a bug in the dart analyzer. Please downgrade it using

dev_dependencies:
  analyzer: 0.38.2

@SergeShkurko
Copy link
Contributor Author

@leisim it works, thanks!

@GAM3RG33K
Copy link

GAM3RG33K commented May 27, 2020

@leisim
I tried downgrading to analyzer v0.38.2 but it doesn't work for me.

By the way, I am not getting this while generating hive adapter but when using it to read from cache on app's restart.

It's a company project so I can't provide code. But I can provide a basic object structure outline for reference.

{
  "meta_data": {}, //small data object, (10-15 string properties)

  "raw_data": [] //a very bug list of small objects( 5-8 numeric properties) with upto 5K objects at a time
}

Can you tell me what the maximum in-memory object size that type adapter can parse at a time?
Thanks in advance.

Update 1 :

When I used jsonString format to store and retrieve the same object via HiveBox then it worked fine and did not throw any error.

Additional info:

Flutter doctor output:

[√] Flutter (Channel beta, v1.17.0, on Microsoft Windows [Version 6.1.7601], locale en-US)
    • Flutter version 1.17.0 at C:\SDK\FlutterSDK\flutter
    • Framework revision e6b34c2b5c (3 weeks ago), 2020-05-02 11:39:18 -0700
    • Engine revision 540786dd51
    • Dart version 2.8.1

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\SDK\Android_SDK
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\SDK\Android_SDK
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.45.1)
    • VS Code at C:\Users\admin\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.10.1

[√] Connected device (3 available)
    • Android SDK built for x86 • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome                    • chrome        • web-javascript • Google Chrome 79.0.3945.130
    • Web Server                • web-server    • web-javascript • Flutter Tools

• No issues found!

======================
dev dependencies

dev_dependencies:
  test: ^1.9.4
  analyzer: 0.38.2 # as per https://github.com/hivedb/hive/issues/63
  build_runner: ^1.0.0
  hive_generator: 0.5.2
  json_serializable: 3.2.3 # https://pub.dev/packages/json_serializable#-readme-tab-
  retrofit_generator: 1.0.2+2 # https://pub.dev/packages/retrofit_generator#-readme-tab-

@bhavikvashi1804
Copy link

This is a bug in the dart analyzer. Please downgrade it using

dev_dependencies:
  analyzer: 0.38.2

as of now when I perform this then I will tell that first run the pub get after running pub get it automatically change the analyzer version to the latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants