I have a destination that accepts a model that have a nullable field. Before, because that nullable field isn't that important (as I have other ways to get the value of that nullable field, basically the nullable field is many-to-many relationship), I didn't bother to get that field's value on my API. But now that I have time to optimize my processes, I finally fixed my API and now I'm also passing the value of the m2m field. But, for some reason, having that value breaks the NavController
's navigate()
, which was previously ok with a null value for that m2m field. Both models are already Serializable. This is the error I'm getting:
The fragment SomeFragment is unknown to the FragmentNavigator. Please use the navigate() function to add fragments to the FragmentNavigator managed FragmentManager
My models looks like this:
data class Account(
@SerializedName("id") var id: String,
... some other fields
@SerializedName("m2m_field") var model1s: List<Model1>?,
) : java.io.Serializable
//Model1 seems to not need @SerializedName(), and I can use it for other Retrofit calls without any issue
//I even got an error when I added @SerializedName() to the fields
data class Model1(
@PrimaryKey(autoGenerate = false) @ColumnInfo(name = "id") var id: String,
@ColumnInfo(name = "created_at") var created_at: String,
... some other fields
) : java.io.Serializable
I already found the answer to this. The cause was kinda silly, the reason was that I have a field on
Model1
that is alright to get null on my use-case, but I didn't declare it as nullable. And something doesn't like that. So check carefully yourRetrofit
response and it's corresponding model and make sure that they are 100% compatible.