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
HiveError: Cannot read, unknown typeId: 38. Did you forget to register an adapter? #332
Comments
I'm not completely sure about why the type id 38 gets mentioned… Hive internally uses 32 reserved type ids, so your id 4 should have become 32 + 4 = 36. More importantly, AFAIK the current Hive architecture doesn't allow for removing adapters. It essentially saves "now come some bytes that the adapter with id 38 knows how to decode and encode". Then it asks the adapter to decode the values – if the adapter is missing, Hive doesn't know how to continue and aborts parsing. |
Exactly. Sorry, my precious answer was wrong: The entry does contain the length and we can just add an |
I have the same problem, i think that there is something wrong cause when i used the typeId: 0 i get HiveError: Cannot read, unknown typeId: 114. for ids more than 0 i get the error on typeId 32 |
Any solution of this? I have typedId from 0 to 33 and error says: |
You have to add '@HiveType(typeId: 1)' at the top of you class name as you can see in this video https://www.youtube.com/watch?v=SFcMdQXnM78&t=619s at 10:19 I asked them to add it to the documentation before it wasnt there |
I've already done that. My code was working, but now is showing that error |
the only thing that i can think of is to try "flutter clean cache" or try to move from channel master to stable |
But we need to know how many bytes should we skip before reading next frame? Also some adapters might write variable length data. So using something like: |
@themisir The first four bytes of any frame are the frame length so knowledge about the adapter is not needed to skip a frame. |
Thanks, @leisim. I'll add |
I have this problem |
Have you registered the adapter using |
Yes it was working before I've updated flutter to 1.20 after the update I've updated hive to |
I've done |
My error comes after second launch when I populate the box with data. At first launch I create the box and register the adapters as well and when I go to a specific page the box will get populated with data and I get no error. But in the second run when the app want's to read the data from the box this error shows up. |
What you can do after following the previous advices is try to delete the created db and create a new one, me when i change database name after flutter clean worked |
My init path is |
I've updated |
Looks like this issue is still happening. After adding a new case to my enum, hive throws this error when reading a class that has this enum property.
I tried calling |
@themisir I ran into some troubles using It seems that the Which - if I'm not mistaken - means
This makes that when using the method without generics: The name of the method is kind of misleading as it makes it seem just passing a
We managed to work around this by calling:
If you need more information, please let me know. I'm not sure what the best fix for this would be. A mention of this problem in the documentation of |
Thanks for letting me know. I could write a type check to ignore (don't use for writes) adapters if T == dynamic so calling |
Hi TheMisir, Thanks for the quick answer. I was just wondering, is it even necessary to have the generic parameter here? If you don't want to use a certain typeId anymore, the I understand that that would be a bigger/breaking change, and your suggested fix will work fine for us as well. |
What i did when I had this problem is I adjusted the typeIds of the other files after it. then I did Uninstalled and Installed the app |
Thanks workaround but it will work if app is not on store. If app is on Store and user are already using it then we need to migrate hive table and it will crash if we change model typeId. any one find out any solution for this? |
Facing same issue. |
same here |
After checking that all the classes were correct, I tried doing flutter clean, flutter clean cache, and wipe the data of the device emulator, and problem solved. |
We just had the same problem. Removed an existing Adapter, and now every time we try to read old data (written when the removed adapter was around), we get that same We added the Hive.ignoreTypeId(N) line, and it keeps failing but now the error is |
Steps to Reproduce
Previous code before the issue
The registration of the adapter:
My Models + Adapter:
So far, so good.
But I want to remove the child object / adapter because we don't need it from now on.
So let's completely remove the
ProjectType
and theProjectTypeAdapter
.And not the App is crashing with the following Issue:
HiveError: Cannot read, unknown typeId: 38. Did you forget to register an adapter?
After a complete new installation everything is working fine.
Version
The text was updated successfully, but these errors were encountered: