I use navigation library and safeargs for passing data. I define argument to fragment like that.
the problem may be with your apply plugin thing please check if you are using java then add:
apply plugin
apply plugin: "androidx.navigation.safeargs"
and for kotlin use this:
apply plugin: "androidx.navigation.safeargs.kotlin"