Why do I get the error Unresolved reference: navArgument when I run the end branch of Android sample project?

Viewed 508

I run the main branch of the official sample project well in Android Studio.

My Android Studio is 2020.3.1 Path 4, and Gradle version is displayed as Image 1.

Image 1 enter image description here

But I get the following error when I try to compile the end branch of the project.

E:\Android_Studio_Sample\android-compose-codelabs\NavigationCodelab\app\src\main\java\com\example\compose\rally\RallyActivity.kt: (31, 36): Unresolved reference: navArgument

How can I fix it?

BTW, I have read article.

I get the following error after I added implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0" to the end branch of the project

Your project has set android.useAndroidX=true, but configuration debugRuntimeClasspath still contains legacy support libraries, which may cause runtime issues. This behavior will not be allowed in Android Gradle plugin 8.0.

And more, I still get the error "Unresolved reference: navArgument" when I added android.enableJetifier=true.

Added content

The project can run when I replace import androidx.navigation.compose.navArgument with import androidx.navigation.navArgument, could you tell me why?

0 Answers
Related