isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
4.11k stars 409 forks source link

HiveError: Cannot read, unknown typeId: 56. Did you forget to register an adapter? #1309

Open senkia24 opened 2 months ago

senkia24 commented 2 months ago

Hello, We are using hive and flutter contacts. We put the contacts to hive box with json format box.put(contact.id, contact.toJson()). Some of ios users faced the HiveError: Cannot read, unknown typeId: 56. Did you forget to register an adapter? error on app start.

It still return error after app uninstall and reinstalled. How do users clear own hive db.


box.values
            .toList()
            .map((e) => Contact.fromJson(
                  Map.from(e.map((key, value) => MapEntry(key.toString(), value))),
                ))
            .toList();
darielkurt commented 2 months ago

@senkia24 you need to register the adapter of the Contact class model

https://docs.hivedb.dev/#/custom-objects/type_adapters?id=register-adapter

uc-asa commented 2 months ago

Hey @darielkurt.

We also get almost same

Non-fatal Exception: FlutterError Exception: HiveError: Cannot read, unknown typeId: 115. Did you forget to register an adapter?

But we just have 4 adaptor.

And It works first time when open app, but when app goes to background and tries to coming back it throws this kind of non fatal and then there is no option to fix.

only uninstall or clearing data cache solves the problem.

Note: this issue we are getting only to few devices

darielkurt commented 2 months ago

Hey @darielkurt.

We also get almost same

Non-fatal Exception: FlutterError Exception: HiveError: Cannot read, unknown typeId: 115. Did you forget to register an adapter?

But we just have 4 adaptor.

And It works first time when open app, but when app goes to background and tries to coming back it throws this kind of non fatal and then there is no option to fix.

only uninstall or clearing data cache solves the problem.

Note: this issue we are getting only to few devices

Can you keyword search "typeId: 115" or "115" on your project directory, then see if there are entries. If you did not find any then I don't know how to continue now.

stuart-rickard commented 1 month ago

I had a similar issue during development of an app, except the typeId was 33. Searched everywhere for this typeId but it didn't exist in the code. All the adapters were registered. Shut down and restarted everything, but the issue remained. I deleted the build assets and that didn't work.

I changed the name of the box which fixed it. Not sure whether you can do this with an installed app, but I think the issue is with a zombie typeId in the stored box. Possibly the build process does not check for zombies. I can volunteer to try to fix it but I probably don't have the skills as a beginner developer.

darielkurt commented 1 month ago

@stuart-rickard

I had a similar issue during development of an app, except the typeId was 33. Searched everywhere for this typeId but it didn't exist in the code. All the adapters were registered. Shut down and restarted everything, but the issue remained. I deleted the build assets and that didn't work.

I changed the name of the box which fixed it. Not sure whether you can do this with an installed app, but I think the issue is with a zombie typeId in the stored box. Possibly the build process does not check for zombies. I can volunteer to try to fix it but I probably don't have the skills as a beginner developer.

I had a similar issue too and it's because of that zombie or floating typeId, even hiveIds can replicate it too. I don't know if it is intentional made by Hive or it is really an issue.