Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio build error in navigation component, action is not abstract and does not implement abstract member actionID

Tags:

Out of nowhere, the build is crashing with a strange error related to the navigation component even though it used to work before, the error is in the generated class, in my case NativeLanguageSelectionFragmentDirections

Here is the error

e: C:\Users\David\StudioProjects\android\app\build\generated\source\navigation-args\debug\com\linguistic\linguistic\framework\presentation\loginscreens\ui\main\NativeLanguageSelectionFragmentDirections.kt: (10, 16): Class 'GoToSelectLearningLangAction' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections
e: C:\Users\David\StudioProjects\android\app\build\generated\source\navigation-args\debug\com\linguistic\linguistic\framework\presentation\loginscreens\ui\main\NativeLanguageSelectionFragmentDirections.kt: (13, 12): 'getActionId' overrides nothing
e: C:\Users\David\StudioProjects\android\app\build\generated\source\navigation-args\debug\com\linguistic\linguistic\framework\presentation\loginscreens\ui\main\NativeLanguageSelectionFragmentDirections.kt: (15, 12): 'getArguments' overrides nothing

And here is the code of the navigation graph

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/first_login_graph.xml"
    app:startDestination="@id/nativeLanguageSelectionFragment">

    <fragment
        android:id="@+id/nativeLanguageSelectionFragment"
        android:name="com.linguistic.linguistic.framework.presentation.loginscreens.ui.main.NativeLanguageSelectionFragment"
        android:label="NativeLanguageSelectionFragment"
        tools:layout="@layout/language_selection_fragment">
        <action
            android:id="@+id/goToSelectLearningLangAction"
            app:destination="@id/learningLanguageSelectionFragment"
            app:enterAnim="@anim/slide_in_right"
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right"
            app:popUpTo="@id/nativeLanguageSelectionFragment"
            app:popUpToInclusive="true" />
    </fragment>
    <fragment
        android:id="@+id/learningLanguageSelectionFragment"
        android:name="com.linguistic.linguistic.framework.presentation.loginscreens.ui.main.LearningLanguageSelectionFragment"
        android:label="LearningLanguageSelectionFragment"
        tools:layout="@layout/language_selection_fragment">
        <argument
            android:name="nativeLanguageID"
            app:argType="string"
            app:nullable="true" />
        <action
            android:id="@+id/action_learningLanguageSelectionFragment_to_welcomeFragment"
            app:destination="@id/welcomeFragment"
            app:enterAnim="@anim/slide_in_right"
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right"
            app:popUpTo="@id/learningLanguageSelectionFragment"
            app:popUpToInclusive="true" />
    </fragment>
    <fragment
        android:id="@+id/welcomeFragment"
        android:name="com.linguistic.linguistic.framework.presentation.loginscreens.ui.main.WelcomeFragment"
        android:label="fragment_welcome"
        tools:layout="@layout/fragment_welcome" />
</navigation>

I am using

 "androidx.navigation:navigation-fragment-ktx:2.3.5"
 "androidx.navigation:navigation-ui-ktx:2.3.5"
like image 973
David Ibrahim Avatar asked May 19 '21 19:05

David Ibrahim


1 Answers

I had this problem too. Until they release the fix. Please try this:

plugins {
  id("androidx.navigation.safeargs")
}

instead of

plugins {
  id("androidx.navigation.safeargs.kotlin")
}
like image 83
Reza Avatar answered Oct 22 '22 05:10

Reza