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

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: HiveError: This should not happen. Please open an issue on GitHub. #828

Closed
ayyyushhhhh opened this issue Nov 10, 2021 · 5 comments
Labels
problem An unconfirmed bug.

Comments

@ayyyushhhhh
Copy link

Steps to Reproduce
I tried to open the Hive box but it is showing the following error.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: HiveError: This should not happen. Please open an issue on GitHub.
E/flutter ( 4038): #0      BinaryReaderImpl.readFrame
package:hive/…/binary/binary_reader_impl.dart:250
E/flutter ( 4038): #1      FrameHelper.framesFromBytes
package:hive/…/binary/frame_helper.dart:21
E/flutter ( 4038): #2      FrameIoHelper.framesFromFile
package:hive/…/io/frame_io_helper.dart:42
E/flutter ( 4038): <asynchronous suspension>
E/flutter ( 4038): #3      StorageBackendVm.initialize
package:hive/…/vm/storage_backend_vm.dart:86
E/flutter ( 4038): <asynchronous suspension>
E/flutter ( 4038): #4      HiveImpl._openBox
package:hive/src/hive_impl.dart:116
E/flutter ( 4038): <asynchronous suspension>
E/flutter ( 4038): #5      HiveImpl.openBox
package:hive/src/hive_impl.dart:145
E/flutter ( 4038): <asynchronous suspension>
E/flutter ( 4038): #6      main
package:time_table/main.dart:38
E/flutter ( 4038): <asynchronous suspension>
E/flutter ( 4038):

Code sample

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  Prefrences.init();
  TasksData.init();
  FirebaseAuthentication.initFirebaseAuth();
  tz.initializeTimeZones();
  NotificationManger.init();

  await Hive.initFlutter();

  Hive.registerAdapter(HabitAdapter());

  await Hive.openBox<Habit>("Habits");   // Error Line
  
  runApp(MyApp());
}

Version

  • Platform: Android,
  • Flutter version: Flutter 2.6.0-12.0.pre.635
  • Hive version: [2.0.4]
  • Hive Flutter version: [1.0.1]

The error is quite inconsistent sometimes you will get the error and sometimes it will work like normal. Although I got this error in debugging mode. I didn't try it with the production app.

@ayyyushhhhh ayyyushhhhh added the problem An unconfirmed bug. label Nov 10, 2021
@2shrestha22
Copy link

Same to me

@masoudk2000
Copy link

I have the same error
I also logged the database file and sent it here.

@HiveType(typeId: 10)
@JsonSerializable(explicitToJson: true)
class SlideDaoDto extends Raw {
  SlideDaoDto(
    int pk,
    bool isActive,
    DateTime createdAt,
    ResourceTypes resourceType,
    int iContentTypeId,
    this.title,
    this.previewSmallId,
    this.previewMediumId,
    this.previewLargeId,
    this.weight,
    this.backgroundColor,
    this.textColor,
    this.iconColor,
    this.contentType,
    this.objectId,
  ) : super(
          pk,
          isActive,
          createdAt,
          resourceType,
          iContentTypeId,
        );

  @HiveField(100)
  final String title;

  @HiveField(101)
  @JsonKey(name: 'preview_small_id')
  final int previewSmallId;

  @HiveField(102)
  @JsonKey(name: 'preview_medium_id')
  final int previewMediumId;

  @HiveField(103)
  @JsonKey(name: 'preview_large_id')
  final int previewLargeId;

  @HiveField(104)
  final int weight;

  @HiveField(105)
  @JsonKey(name: 'background_color')
  final String backgroundColor;

  @HiveField(106)
  @JsonKey(name: 'text_color')
  final String textColor;

  @HiveField(107)
  @JsonKey(name: 'icon_color')
  final String iconColor;

  @HiveField(108)
  @JsonKey(name: 'content_type')
  final int? contentType;

  @HiveField(109)
  @JsonKey(name: 'object_id')
  final String? objectId;

  factory SlideDaoDto.fromJson(Map<String, dynamic> json) =>
      _$SlideDaoDtoFromJson(json);

  Map<String, dynamic> toJson() => _$SlideDaoDtoToJson(this);
}

slide_local_data_source.zip

Thank you for your help soon
@themisir

@masoudk2000
Copy link

No one to help us?

@themisir
Copy link
Contributor

No one to help us?

I wish it was that easy 😅 I've spend a lot of time investigating this issue but haven't found any clue on why that's happening. Most obvious reason looks like is: invalid configuration but I am not sure.

Also closed as duplicate of #263

@themisir
Copy link
Contributor

Note: I've closed this one because there's already discussion regarding this issue on #263. I have no idea how this could be solved, I have used hive in production of multiple apps but haven't experienced this issue. Since hive is an open source project any help regarding this issue would be appreciated as I can't spend as much time on the issue I have no clue on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem An unconfirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants