I wanted to try new Navigation library. After following this guideline I experienced error at runtime:
Caused by: android.view.InflateException: Binary XML file
NavHostFragment
is not accessible?android:name="androidx.navigation.fragment.NavHostFragment
So in your build.gradle
, just add this two dependencies -
For Java:-
dependencies {
def nav_version = "2.3.0"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
}
For Kotlin:-
dependencies {
def nav_version = "2.3.0"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
}
Reference Link:- https://developer.android.com/jetpack/androidx/releases/navigation