I use navigation library and safeargs for passing data. I define argument to fragment like that.
As Christian wrote, adding source set do app gradle file helped. The problem occurs in Android Studio 4.1 and 4.2 for me. In Kotlin DSL:
android { .... sourceSets { getByName("main").java.srcDirs("build/generated/source/navigation-args") } }