contains returns true but get returns null
Please try to fill all questions below before submitting an issue.
- [x] On which android versions do you have this issue? : 7.1.1
- [x] On which phones do you have this issue? : Nexus 5
- [x] Which hawk version are you using? : 2.0.1
- [x] Does this issue happen always or is it flaky? : always
- [ ] Can you write failing test? :
Caused by: java.lang.NullPointerException:
- [x] If it is Hawk.put and Hawk.get issue, can you write down which data you were trying to save and get it back?
03-01 10:44:26.462 App: Hawk.get -> key: key_current_i
03-01 10:44:26.462 App: Hawk.get -> Fetched from storage : com.app.user.User##0V@AQKZOe3sJLezNxTjOxG49Qbzzx5WU2geNS7XiGR2RFdz3QmwoupbYLY1jzL4OdWlhOyQD53S9R12nk5HpVxgkSnGVKfhb/BLa9amFUern1WBCd4UH9jKfDrFW2gxmeSPd2EFnuAG0P8D5XaZL7pA9F9o/ygeujnNJyc+Da6eA8On5CSgnyxCPQTdet/e9TPLpXzcaNcNcmQaspzg88J4Yi4OSOnANBGCU0aM+hLsFN6d68TrLD4tcBbHIx06L66PAHA5oI4cvy+B3hhtQHQh7uM7nQ04YsiuVQd3aj6TuewJbVFCpe40BjnLQtPeWY9jfxbbcvx4maLyQ5mILz+kBlPekRSJeteGeUaD4A26y8JcAWx8/9+4OsP2mPiG/I7tjyLd2vPa55N9JbCUuGbXrkBVxmgukbRgSYgUUTHCuREp7WbT+uPEG7oKaow3qCgC5avKuHibiNPwMUNhQ8426NBZljsnxXeoBBniBMfv74IrZ9AzY9DSwKNuOiHPLdb9umid3Ik8u2Hj
03-01 10:44:26.463 App: Hawk.get -> Deserialized
03-01 10:44:26.464 App: Hawk.get -> Decrypted to : {"mToken":"FakeToken","email":"[email protected]","firstName":"..","lastName":"ALOUANE","mLastLocationLat":0.0,"mLastLocationLon":0.0,"mPhotoUrl":{"cachedFsi":-2,"cachedSsi":-2,"scheme":"NOT CACHED","uriString":"https://lh4.googleusercontent.com/-oZ9tCuiyQ6k/AAAAAAAAAAI/AAAAAAAACsU/ZkpZNZ4XvCg/s96-c/photo.jpg","host":"NOT CACHED","port":-2},"score":0}
03-01 10:44:26.466 App: Hawk.get -> Converter failed
- [x] Is the data you are trying to save it huge or small? small
Hi, I had this problem in my app too, the problem was that I changed my Java's packages structure and I was using Hawk to store an instance of one of my objects. Hawk stores the path of the class to recreate it with GSON, when I was trying to get my object back there was an error because it had the old path to my class and couldn't know that I moved my class in an other package.
👍 I'll check and maybe change the implementation a little bit.
+1
I faced with the same issue on release build and fixed with preventing the class member name that will be serialized/deserialized obfuscation by proguard.