Safeargs library doesnt generate direction class

前端 未结 19 1405
孤街浪徒
孤街浪徒 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:17

    Follow these steps:

    Step 1: Add dependencies

    def nav_version = "2.3.2"
    
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    

    Step 2: In your app-level build.gradle make sure you have below plugins added.

    plugins {
        id 'com.android.application'
        id 'kotlin-android'
        id 'kotlin-kapt'
        id 'kotlin-android-extensions'
        id 'androidx.navigation.safeargs.kotlin'
    }
    

    Step 3: Add this in project_level build.gradle inside dependencies section :

    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.2"
    

    Step 4: In your nav_graph.xml make sure to connect one fragment to another with actions.

    Step 5: Clean & Rebuild your project.

提交回复
热议问题