导航图中的 ClassNotFoundException android

WIS*_*SHY 5 android classnotfoundexception kotlin android-navigation android-navigation-graph

我在 firebase 上看到了这个崩溃,并且在相同操作系统的模拟器中无法重现。不知道是什么原因造成的。三星 M32 OS 11 发生崩溃。

崩溃是

Caused by java.lang.RuntimeException: java.lang.ClassNotFoundException: com.octave.data.offer.Classes
Run Code Online (Sandbox Code Playgroud)

这是导航图

<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/offer_nav_graph"
app:startDestination="@id/offersFragment">

<fragment
    android:id="@+id/availableOfferDetailFragment"
    android:name="com.octave.offers.available.detail.AvailableOfferDetailFragment"
    android:label="fragment_available_offer_detail"
    tools:layout="@layout/fragment_available_offer_detail">
    <action
        android:id="@+id/action_availableOfferDetailFragment_to_applyOfferFragment"
        app:destination="@id/applyOfferFragment">
        <argument
            android:name="classes"
            app:argType="com.octave.data.offer.Classes[]" />
        <argument
            android:name="paymentPlans"
            app:argType="com.octave.data.offer.PaymentPlan[]" />
        <argument
            android:name="offerName"
            app:argType="string" />
    </action>
</fragment></navigation>
Run Code Online (Sandbox Code Playgroud)

我的数据类如下

@Parcelize
data class Classes(
val id: Int,
val name: String,
val totalEquity: Int,
val reservedEquity: Int,
val expectedReturn: Float,
val subscribed: Int
):Parcelable

@Parcelize
data class PaymentPlan(
val id: String?=null,
val name: String,
var payment: Int,
val date: String
):Parcelable
Run Code Online (Sandbox Code Playgroud)

小智 5

这可能与混淆有关。以下是任何使用 @Parcelize 注释的类的规则:

-保留@kotlinx.parcelize.Parcelize公共类*

请注意,它适用于 kotlinx.parcelize.Parcelize,而不适用于已弃用的替代品 kotlinx.android.parcel.Parcelize。