Hello! Anyone faced issue like this? I’m just star...
# decompose
m
Hello! Anyone faced issue like this? I’m just starting to use decompose so it might be that I’m doing something wrong. I get this error when I try to build Android app, but iOS app builds and runs with same code in shared module.
Copy code
e: /***/shared/src/commonMain/kotlin/*/*/*/root/RootComponent.kt: (38, 10): This class does not have a constructor
Line that reports is where I use
@Parcelize
annotation. I use latest version of decompose: 1.0.0-alpha-07-native-compose. I will share code in 🧵 ⬇️
Copy code
package somepackage.root

import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.router.stack.StackNavigation
import com.arkivanov.decompose.router.stack.childStack
import com.arkivanov.decompose.value.Value
import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import somepackage.LoginComponent
import somepackage.LoginComponentImpl

interface RootComponent {
    val routerState: Value<ChildStack<*, Child>>

    sealed class Child {
        data class Login(val component: LoginComponent) : Child()
    }
}

class RootComponentImpl(context: ComponentContext) : ComponentContext by context, RootComponent {
    private val navigation = StackNavigation<Config>()

    override val routerState: Value<ChildStack<*, RootComponent.Child>>
        get() = childStack(
            source = navigation,
            initialConfiguration = Config.Login,
            handleBackButton = true,
            childFactory = ::createChild
        )

    private fun createChild(config: Config, context: ComponentContext) = when (config) {
        is Config.Login -> RootComponent.Child.Login(LoginComponentImpl(context))
    }

    sealed class Config : Parcelable {

        @Parcelize
        object Login : Config()
    }
}
a
Does the project compile from the command line?
m
Nope it also throws same error. Tried with
./gradlew assembleStagingDebug
But I also noticed now that it also throws another error:
Copy code
***/RootComponent.kt: (39, 9): Object 'Login' is not abstract and does not implement abstract base class member public abstract fun describeContents(): Int defined in somepackage.root.RootComponentImpl.Config
But this doesn’t make sense also 🤔 IDE (Android Studio) doesn’t highlight any errors.
a
Yeah, this is weird. Never seen this error before. What kotlin version are you using? Would you be able to provide a reproducer project?
Did you apply the parcelize Gradle plugin?
m
BINGO! I think I didn’t 🤦🏻‍♂️ Let me double check
Yep thank you very much @Arkadii Ivanov It was Gradle plugin I forgot, it works now 🙂
a
Glad to help!
a
i also face this issue before and now too . and i search through slack channel to remember what was wrong . i think you should mention to add this plugin in the documentation -> getting started -> Installation . as its clearly a mandatory for decompose . anyway i tried this on compose-ios now and ios part works without applying the plugin .
a
Thanks for the feedback! That's mentioned in the corresponding docs section (it's highlighted with a warning box) - https://arkivanov.github.io/Decompose/navigation/overview/#configurations-are-parcelable
The Installation section also makes sense. I will update the docs.