I tried to implement the Navigation feature in my app. When I try to build the app the output says:
Android resource linking failed
/home/mateusz/AndroidStudioProjects/TakeAndTie/app/src/main/res/layout/activity_main.xml:23: error: attribute defaultNavHost (aka com.mateuszpolito.takeandtie:defaultNavHost) not found.
/home/mateusz/AndroidStudioProjects/TakeAndTie/app/src/main/res/layout/activity_main.xml:23: error: attribute navGraph (aka com.mateuszpolito.takeandtie:navGraph) not found.
error: failed linking file resources.
Here is the nav_host_fragment from activity_main.xml:
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph" />
I have implemented navigation in my app level build.gradle:
implementation "androidx.navigation:navigation-ui-ktx:2.1.0-alpha02"
I am using Android Studio version 3.4
Can you add to build.gradle of the project:
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.2.0-alpha03"
and in app/build.gradle
apply plugin: "androidx.navigation.safeargs.kotlin"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
Only change your activity_main.xml:
xmlns:app="http://schemas.android.com/apk/res-auto"
to
xmlns:app="http://schemas.android.com/apk/res"
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