Open firdausmaulan opened 3 years ago
@NonNull
generates a null
-check and if you set one value to null
that check throws an exception. Is it possible that you accidentally imported the lombok annotation instead of a specific Room/android annotation?
I've check my code, and I imported from androidx room.
import androidx.room.PrimaryKey;
I just downgrade lombok version to 1.18.10 and everything going well.
The problem is that you added a @NonNull
annotation to a field and try to assign null
to that field. Lombok detects the annotation and generates code that prevents null
values. This is intended. Simply remove the annotation and it should work.
Edit:
I think I should explain a little bit why you should remove the @NonNull
annotation even if you would not use lombok at all. @PrimaryKey(autoGenerate = true)
generates a primary key if the Long
field is null
. At the same time you added a @NonNull
annotation (I guess you used androidx.annotation.NonNull
) which indicates that the field can never be null
. You cannot get both things at the same time because you need null
for autoGenerate = true
.
Describe the bug I'm using Lombok & Room in my android project Everything going well, until I update Lombok to version 1.18.16 It's look like new version not compatible with Room annotation @PrimaryKey(autoGenerate = true) And it's throw error : java.lang.NullPointerException: id is marked non-null but is null
To Reproduce
Just insert the data and crash
Expected behavior
Version info (please complete the following information):
Additional context https://developer.android.com/jetpack/androidx/releases/room