I fetch this below code from
But getting this below error: spend already more the 3 hours but not any success.
Please help me to solve this error.
In its own words, AndroidX Navigation is “a framework for navigating between 'destinations' within an Android application that provides a consistent API whether destinations are implemented as Fragments, Activities, or other components.”
In the Project window, right-click on the res directory and select New > Android Resource File. The New Resource File dialog appears. Type a name in the File name field, such as "nav_graph". Select Navigation from the Resource type drop-down list, and then click OK.
Android Jetpack's Navigation component helps you implement navigation, from simple button clicks to more complex patterns, such as app bars and the navigation drawer. The Navigation component also ensures a consistent and predictable user experience by adhering to an established set of principles.
Change this
implementation 'android.arch.navigation:navigation-fragment-ktx:2.2.0-alpha01'
implementation 'android.arch.navigation:navigation-ui-ktx:2.2.0-alpha01'
to this:
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.0-alpha01'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.0-alpha01'
Notice that android.arch.navigation is replaced with androidx.navigation
also, make sure to apply this plugin on top of build.gradle:
apply plugin: "androidx.navigation.safeargs.kotlin"
and this to the dependencies to the project level build.gradle:
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-rc01"
If you are using kotlin and androidX than replace this
apply plugin: "androidx.navigation.safeargs"
with
apply plugin: "androidx.navigation.safeargs.kotlin"
and in project level build.gradle
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha01"
}
on app level build.gradle
def nav_version = "2.1.0-alpha01"
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
If you are using kotlin Ktx
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
Hope this will help other people also. It helps me too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With