3

To prevent Lint warning (replace fragment with FragmentContainerView) after upgrading to latest fragments (1.2.2 version) and navigation (2.2.1 version) I replaced fragment with FragmentContainerView

<androidx.fragment.app.FragmentContainerView
    android:id="@+id/nav_host_fragment"
    android:name="androidx.navigation.fragment.NavHostFragment"
    ....
    app:defaultNavHost="true"
    app:navGraph="@navigation/nav_graph" />

But after that I found error in my @navigation/nav_graph - This navigation graph is not referenced to any layout files

Everything works fine, but that error is very annoying.

Sever
  • 2,338
  • 5
  • 35
  • 55
  • Looks like we need just ignore this error as I see the same error for navigation graphs on https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample – Sever Feb 29 '20 at 22:23
  • What version of Android Studio are you using? – ianhanniballake Feb 29 '20 at 22:37
  • @ianhanniballake Im using latest stable => AS 3.6.0 and 3.6.1 – Sever Feb 29 '20 at 22:53
  • Does this answer your question? [Using FragmentContainerView with Navigation component?](https://stackoverflow.com/questions/58320487/using-fragmentcontainerview-with-navigation-component) – Rule Apr 18 '20 at 13:32
  • @Rule, Unfortunately, does not help. – Sever Apr 18 '20 at 21:50

4 Answers4

0

It might be that I understand this wrong, but if everything works, this might be a classic case of Android Studio being in need of some cache clearing and restarting. Maybe even manually deleting build folders from your project.

Primož Ivančič
  • 1,984
  • 1
  • 17
  • 29
  • 1
    No, I tried clean/sync gradle/refresh/invalidate and etc. Error disappears only when I revert FragmentContainerView back to fragment. Looks like classic google fails with "stable" libs :) For now, I just suppress error with tools:ignore="UnusedNavigation" – Sever Feb 29 '20 at 22:06
0

You need to update to the latest versions of the navigation-fragment-ktx in your build.gradle(app)

def nav_version = "2.3.0-alpha03"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
0

Had the same "false" warning, seems it will be fixed in a future release. Meanwhile, as Android Studio suggests, the warning can be safely ignored using:

<navigation
    ...
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="UnusedNavigation" />
BamsBamx
  • 4,139
  • 4
  • 38
  • 63
-1

I have the same error however, the app compiles fine and works. I suppose we have to wait for fix in the next stable release.

unferna
  • 105
  • 1
  • 2