'ClassNotFoundException in navigation graph android
I saw this crash over firebase and it is not reporducible in the emulator of same OS. Not sure what is causing it. Crash is occuring in samsung M32 OS 11.
The crash is
Caused by java.lang.RuntimeException: java.lang.ClassNotFoundException: com.octave.data.offer.Classes
This is the navigation graph
<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>
And my data classes are as follows
@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
Solution 1:[1]
It could be related to obfuscation. Here's a rule for any class annotated with @Parcelize:
-keep @kotlinx.parcelize.Parcelize public class *
Note it's for kotlinx.parcelize.Parcelize and not for the deprecated alternative kotlinx.android.parcel.Parcelize.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | BtdJB |