Safeargs library doesnt generate direction class

前端 未结 19 924
孤街浪徒
孤街浪徒 2021-02-01 11:44

I use navigation library and safeargs for passing data. I define argument to fragment like that.



        
19条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 12:15

    In my case, the missing part was firstly in the build.gradle.kts

    buildscript {
    repositories {
        google()
    }
    dependencies {
        def nav_version = "X.X.X" // Use the latest version
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    }
    

    }

    and then, I had to add the plugin in app and navigation modules (I usually separate navigation in a different one):

    apply plugin: "androidx.navigation.safeargs.kotlin"
    

    Clean -> Build But still had to add manually the path to the action

    import yourpackage.FragmentDirections.Companion.actionFirstFragmentToSecondFragment
    

提交回复
热议问题