Object is not abstract and does not implement abstract base class member public abstract fun describeContents(): Int
Deaths-Door opened this issue ยท 7 comments
import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
sealed class RootGraph : Parcelable {
@Parcelize object UserLibrary : RootGraph()
@Parcelize object ExploreNewContent : RootGraph()
@Parcelize object EventMaps : RootGraph()
@Parcelize object LocalMusic : RootGraph()
// @Composable
// abstract fun content(globalViewModel : GlobalViewModel)
}
I get error
- This class does not have a constructor
- Object is not abstract and does not implement abstract base class member public abstract fun describeContents(): Int defined in com.deathsdoor.chillback.common.ui.navigation.RootGraph but then i can't manually override the function if i want to
Also the doc is lacking , i mean so push function for router
Hi. Thanks for the issue. Have you included the parcelize plugin on your module?
This is required for android, just like any other android module
Yes i tried with parcelize plugin , and different versions of the 'optional' (other) libraries as well but i get that issue. If i but @parcelize on the class itself i get , Object is not abstract and does not implement abstract base class member public abstract fun describeContents(): Int defined in some decompose package. As well as , I am unable to 'find' the methods given in the doc
I see what the issue is.
You should only need to annotate with @Parcelize
once on the top-level sealed class. Here's the sample implementation
@Parcelize
sealed class StoryHomeScreen: Parcelable {
object List: StoryHomeScreen()
data class Details(val section: TopStorySection, val uri: ArticleUri, val title: String): StoryHomeScreen()
}
The documentation is wrong and I will use this issue to correct this. Thanks for pointing this out ๐ Hopefully the above fix works for you
Thanks , that solved the issue and since you are fixing the README , maybe change
val commonMain by getting {
dependencies {
implementation("io.github.xxfast:decompose-router:${versions.decompose-router}")
// You will probably need to also bring in decompose and essenty
implementation("com.arkivanov.decompose:decompose:${versions.decompose}")
implementation("com.arkivanov.decompose:extensions-compose-jetbrains:${versions.decompose}")
implementation("com.arkivanov.essenty:parcelable:${versions.essenty}")
}
}
as the other libraries are needed else you can't use the router at all
Yup will do
I have just checked and the original code works for me just fine. I mean, kotlin-parcelize
plugin should work both ways. Not sure what was the actual issue.
yeah, you are right @arkivanov, I'm assuming the issue was an outdated cache prior to adding kotlin-parcelize
Nevertheless, I've update the readme (in #15) to go with the simpler approach of declaring @Parcelize
once on the sealed type