But getting this below error: spend already more the 3 hours but not any success.
Please help me to solve this error.
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
Another possible case:
Check in your code that you have actually defined argument tag in the xml file (sender && receiver).
In another case, Args will not be generated.
Following code will not generate Args:
<fragment
android:id="@+id/receiverFragment"
android:name="com.example.app.ReceiverFragment"
android:label="ReceiverFragment" >
</fragment>
Following code will generate Args:
<fragment
android:id="@+id/receiverFragment"
android:name="com.example.app.ReceiverFragment"
android:label="ReceiverFragment" >
<argument
android:name="myArgument"
app:argType="integer"
app:nullable="false" />
</fragment>
In your build.gradle app level add this:
apply plugin: 'androidx.navigation.safeargs'
Update:
This codelab is very old try not updating libraries.
apply plugin: 'androidx.navigation.safeargs'
Already there in app level gradle. –
Branchiopod Try to add
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha05"
Instead of
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-rc02"
Version 3.3.1 of Android Studio have similar problems like this but solution is simple. Close project and Import your project again. You will see the result.
I tried everything which is written above i.e adding all plugins and dependencies (which is completely right though) but I was doing this silly mistake -> I was creating navArgs variable outside the fragment
Don't ->
private val args by navArgs<VideoCallFragmentArgs>()
class YourFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_video_call, container, false)
}
}
Always create navArgs variable inside the fragment.
Do ->
class YourFragment : Fragment() {
private val args by navArgs<VideoCallFragmentArgs>()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_video_call, container, false)
}
}
© 2022 - 2024 — McMap. All rights reserved.
DeepLinkFragmentArgs
FlowStepFragmentArgs
FlowStepFragmentDirections
this all are auto generated class. – Branchiopod