导航图方向构建失败

Navgraph direction build fail

我尝试 运行 我的应用程序时构建失败。 那是我的错误:

Class 'ActionGlobalEventHolder' is not abstract and does not implement abstract member public abstract val actionId: Int defined in androidx.navigation.NavDirections

除此之外,我还遇到了这些错误:

'getActionId' overrides nothing

并且:

'getArguments' overrides nothing

我生成的导航图方向class:

   public class NavGraphDirections private constructor() {
  private data class ActionGlobalEventHolder(
    public val eventid: Int = -1
  ) : NavDirections {
    public override fun getActionId(): Int = R.id.action_global_eventHolder

    public override fun getArguments(): Bundle {
      val result = Bundle()
      result.putInt("eventid", this.eventid)
      return result
    }
  }

  public companion object {
    public fun actionGlobalHomeFragmentAll(): NavDirections =
        ActionOnlyNavDirections(R.id.action_global_home_Fragment_All)

    public fun actionGlobalMapFragment(): NavDirections =
        ActionOnlyNavDirections(R.id.action_global_map_Fragment)

    public fun actionGlobalEventHolder(eventid: Int = -1): NavDirections =
        ActionGlobalEventHolder(eventid)

    public fun actionGlobalFavouriteFragment(): NavDirections =
        ActionOnlyNavDirections(R.id.action_global_favourite_Fragment)

    public fun actionGlobalNetworkBottomSheet2(): NavDirections =
        ActionOnlyNavDirections(R.id.action_global_networkBottomSheet2)

    public fun actionGlobalSearchDialog(): NavDirections =
        ActionOnlyNavDirections(R.id.action_global_searchDialog)
  }

我的导航图:

<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/nav_graph"
app:startDestination="@id/home_Fragment_KT">
<fragment
    android:id="@+id/home_Fragment_KT"
    android:name="de.n.newnightstar.ui.mains.HomeFragment"
    android:label="Home_Fragment_KT"
    tools:layout="@layout/fragment_home_all">
    <action
        android:id="@+id/actionhome_Fragment_KT_to_eventHolder"
        app:destination="@id/eventHolder"
        app:enterAnim="@anim/holderslideinright"
        app:exitAnim="@anim/holderslideoutleft"
        app:popEnterAnim="@anim/holderslideinleft"
        app:popExitAnim="@anim/holderslideoutright" />
    <action
        android:id="@+id/action_home_Fragment_KT_to_login2"
        app:popUpTo="@id/login2" />
    <action
        android:id="@+id/action_home_Fragment_KT_to_config_Filter"
        app:destination="@id/config_Filter" />
</fragment>
<fragment
    android:id="@+id/map_Fragment"
    android:name="de.n.newnightstar.ui.mains.Map_Fragment"
    android:label="Map_Fragment" >
    <action
        android:id="@+id/action_map_Fragment_to_mapBottomSheet"
        app:destination="@id/mapBottomSheet" />
</fragment>
<fragment
    android:id="@+id/favourite_Fragment"
    android:name="de.n.newnightstar.ui.mains.Favourite_Fragment"
    android:label="fragment_favourite_"
    tools:layout="@layout/fragment_favourite_" />
<fragment
    android:id="@+id/eventHolder"
    android:name="de.n.newnightstar.ui.Fragments.Details.EventHolderKT"
    android:label="fragment_event_holder">
    <action
        android:id="@+id/action_eventHolder_to_eventLocationMain"
        app:destination="@id/eventLocationMain"
        app:enterAnim="@anim/holderslideinright"
        app:exitAnim="@anim/holderslideoutleft"
        app:popEnterAnim="@anim/holderslideinleft"
        app:popExitAnim="@anim/holderslideoutright" />
    <action
        android:id="@+id/action_eventHolder_to_mapDetails"
        app:destination="@id/mapDetails" />
    <argument
        android:name="eventid"
        android:defaultValue="-1"
        app:argType="integer" />
</fragment>
<dialog
    android:id="@+id/accountverify"
    android:name="de.n.newnightstar.ui.Fragments.AccountFragments.accountverify"
    android:label="accountverify" />
<dialog
    android:id="@+id/registration"
    android:name="de.n.newnightstar.ui.Fragments.AccountFragments.Registration"
    android:label="fragment_registration"
    tools:layout="@layout/fragment_registration" >
    <action
        android:id="@+id/action_registration_to_accountverify"
        app:destination="@id/accountverify" />
    <action
        android:id="@+id/action_registration_to_login2"
        app:destination="@id/login2" />
</dialog>
<dialog
    android:id="@+id/login2"
    android:name="de.n.newnightstar.ui.Fragments.AccountFragments.Login"
    android:label="fragment_login"
    tools:layout="@layout/fragment_login" >
    <action
        android:id="@+id/action_login2_to_registration"
        app:destination="@id/registration" />
</dialog>
<activity
    android:id="@+id/mainActivity"
    android:name="de.n.newnightstar.ui.Activity.MainActivity"
    android:label="activity_main"
    tools:layout="@layout/activity_main"

    />
<action
    android:id="@+id/action_global_home_Fragment_All"
    app:destination="@id/home_Fragment_KT" />
<action
    android:id="@+id/action_global_map_Fragment"
    app:destination="@id/map_Fragment"
     />
<action
    android:id="@+id/action_global_eventHolder"
    app:destination="@id/eventHolder"
    app:enterAnim="@anim/holderslideinright"
    app:exitAnim="@anim/holderslideoutleft"
    app:popEnterAnim="@anim/holderslideinleft"
    app:popExitAnim="@anim/holderslideoutright">

我试图搜索解决方案,但没有找到任何东西,也不知道为什么我在生成的 class 中出现此错误。 我将 android studio 更新到最新版本,之后我做了一些改动。我试图删除一些动作并尝试获得新的导航图方向,但我也遇到了同样的错误。 我自己无法解决问题,也没有找到解决方案。 如果有任何帮助,我将不胜感激!

我的build.gradle:

    plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id "androidx.navigation.safeargs.kotlin"
    id 'kotlin-android-extensions'
}

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "de.n.newproject"
        minSdkVersion 25
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
        dataBinding true
    }
}

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
        google()

    }
}
dependencies {
    def epoxyVersion = "4.6.2"
    // Jetpack Navigation

    // Networking
    debugImplementation "com.github.chuckerteam.chucker:library:3.4.0"
    releaseImplementation "com.github.chuckerteam.chucker:library-no-op:3.4.0"

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'

    // Moshi
    implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
    implementation 'com.squareup.moshi:moshi-kotlin:1.12.0'

    // Picasso
    implementation "com.airbnb.android:epoxy:$epoxyVersion"
    implementation "com.airbnb.android:epoxy-paging:$epoxyVersion"
    implementation "com.airbnb.android:epoxy-paging3:$epoxyVersion"
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    kapt  'android.arch.persistence.room:compiler:1.1.1'
    kapt 'android.arch.persistence.room:compiler:1.1.1'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation  'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31'
    implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    implementation "androidx.room:room-ktx:2.4.0-alpha05"
    implementation "androidx.room:room-rxjava2:2.4.0-alpha05"
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
    implementation "androidx.room:room-runtime:2.4.0-alpha05"
    implementation "androidx.room:room-ktx:2.4.0-alpha05"
    implementation "io.coil-kt:coil:0.11.0"
    implementation "androidx.paging:paging-runtime-ktx:3.0.1"
    // alternatively - without Android dependencies for tests
    testImplementation "androidx.paging:paging-common-ktx:3.0.1"
    // optional - RxJava2 support
    implementation "androidx.paging:paging-rxjava2-ktx:3.0.1"
    // optional - RxJava3 support
    implementation "androidx.paging:paging-rxjava3:3.0.1"
    // optional - Guava ListenableFuture support
    implementation "androidx.paging:paging-guava:3.0.1"
    // optional - Jetpack Compose integration
    implementation "androidx.paging:paging-compose:1.0.0-alpha13"
    implementation "androidx.paging:paging-guava:3.0.1"
    implementation 'com.github.pratikbutani:MultiSelectSpinner:1.0.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation 'com.google.maps.android:android-maps-utils:2.2.2'
    implementation platform('com.google.firebase:firebase-bom:26.8.0')
    implementation 'com.google.firebase:firebase-dynamic-links'
    implementation "com.google.firebase:firebase-firestore:23.0.3"
    implementation "com.google.android.gms:play-services-auth:19.2.0"
    implementation 'com.google.firebase:firebase-analytics:19.0.1'
    implementation 'com.facebook.shimmer:shimmer:0.5.0'
    implementation 'org.parceler:parceler-api:1.1.13'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
    kapt 'org.parceler:parceler:1.1.13'
    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation "androidx.room:room-runtime:2.3.0"
    implementation 'androidx.paging:paging-runtime-ktx:3.0.1'
    kapt "androidx.room:room-compiler:2.3.0"
    androidTestImplementation "androidx.room:room-testing:2.3.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
    implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
    implementation "androidx.datastore:datastore-rxjava2:1.0.0"
    implementation "androidx.datastore:datastore-preferences:1.0.0"
    implementation "androidx.navigation:navigation-dynamic-features-fragment:2.3.5"
    androidTestImplementation "androidx.navigation:navigation-testing:2.3.5"
    implementation "androidx.navigation:navigation-compose:2.4.0-alpha10"
    implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
    implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
    implementation 'org.greenrobot:eventbus:3.2.0'
    implementation 'pub.devrel:easypermissions:3.0.0'
    implementation "androidx.fragment:fragment-ktx:1.3.6"
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.exifinterface:exifinterface:1.3.3'
    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'com.google.android.libraries.places:places:2.4.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.gms:play-services-auth:19.2.0'
    implementation 'com.google.android.gms:play-services-location:18.0.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.1'
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'androidx.navigation:navigation-runtime-ktx:2.3.5'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
 

项目级别gradle:

buildscript {
    repositories {
        ext.kotlin_version = '1.5.31'
        google()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
        classpath 'com.google.gms:google-services:4.3.10'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是 kotlin safeargs 插件错误。尝试将 androidx.navigation.safeargs.kotlin 更改为 androidx.navigation.safeargs