Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object is not abstract and does not implement abstract base class member public abstract fun describeContents(): Int #14

Closed
Deaths-Door opened this issue May 25, 2023 · 7 comments

Comments

@Deaths-Door
Copy link

Deaths-Door commented May 25, 2023

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

@xxfast
Copy link
Owner

xxfast commented May 28, 2023

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

@Deaths-Door
Copy link
Author

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

@xxfast
Copy link
Owner

xxfast commented May 29, 2023

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

@Deaths-Door
Copy link
Author

Deaths-Door commented May 29, 2023

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

@xxfast
Copy link
Owner

xxfast commented Jun 1, 2023

Yup will do

@arkivanov
Copy link
Contributor

arkivanov commented Jun 5, 2023

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.

@xxfast
Copy link
Owner

xxfast commented Jun 6, 2023

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

@xxfast xxfast closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants