NavHostFragment not accessible from XML

前端 未结 6 1595
天涯浪人
天涯浪人 2021-02-14 06:08

I wanted to try new Navigation library. After following this guideline I experienced error at runtime:

Caused by: android.view.InflateException: Binary XML file          


        
6条回答
  •  我在风中等你
    2021-02-14 06:49

    Adding dependencies from Android Developers helped me:

    dependencies {
       def nav_version = "2.3.0-rc01"
    
      // Java language implementation
      implementation "androidx.navigation:navigation-fragment:$nav_version"
      implementation "androidx.navigation:navigation-ui:$nav_version"
    
      // Kotlin
      implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
      implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    
      // Dynamic Feature Module Support
      implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"
    
      // Testing Navigation
      androidTestImplementation "androidx.navigation:navigation-testing:$nav_version"
    }
    

提交回复
热议问题