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

BadParcelableException when destination accepts interface argument #60

Closed
pchmielowski opened this issue Feb 16, 2022 · 5 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@pchmielowski
Copy link

pchmielowski commented Feb 16, 2022

Hi! I've encountered a following exception:

    android.os.BadParcelableException: java.lang.NoSuchFieldException: CREATOR
        at com.ramcosta.composedestinations.navargs.parcelable.DefaultParcelableNavTypeSerializer.getParcelableCreator(DefaultParcelableNavTypeSerializer.kt:58)
        at com.ramcosta.composedestinations.navargs.parcelable.DefaultParcelableNavTypeSerializer.base64ToParcelable(DefaultParcelableNavTypeSerializer.kt:39)
        at com.ramcosta.composedestinations.navargs.parcelable.DefaultParcelableNavTypeSerializer.fromRouteString(DefaultParcelableNavTypeSerializer.kt:24)
        at net.chmielowski.pill.ui.navtype.ArgumentNavType.parseValue(ArgumentNavType.kt:26)
        at net.chmielowski.pill.ui.navtype.ArgumentNavType.parseValue(ArgumentNavType.kt:13)
        at androidx.navigation.NavType.parseAndPut(NavType.kt:80)
        at androidx.navigation.NavDeepLink.parseArgument(NavDeepLink.kt:228)
        at androidx.navigation.NavDeepLink.getMatchingArguments(NavDeepLink.kt:173)
        at androidx.navigation.NavDestination.matchDeepLink(NavDestination.kt:347)
        at androidx.navigation.NavGraph.matchDeepLink(NavGraph.kt:72)
        at androidx.navigation.NavController.navigate(NavController.kt:1648)
        at androidx.navigation.NavController.navigate(NavController.kt:1980)
        at androidx.navigation.NavController.navigate$default(NavController.kt:1975)
        at androidx.navigation.NavController.navigate(NavController.kt:1961)
        at com.ramcosta.composedestinations.navigation.DestinationsNavController.navigate(DestinationsNavController.kt:27)
        at com.ramcosta.composedestinations.navigation.DestinationsNavigator$DefaultImpls.navigate(DestinationsNavigator.kt:40)
        at com.ramcosta.composedestinations.navigation.DestinationsNavController.navigate(DestinationsNavController.kt:13)
        at com.ramcosta.composedestinations.navigation.DestinationsNavigator$DefaultImpls.navigate$default(DestinationsNavigator.kt:35)

It happens right after clicking the button, when navigate() is called:

@Composable
@Destination(start = true)
fun First(navigator: DestinationsNavigator) {
    Button(onClick = { navigator.navigate(SecondDestination(ArgumentImpl(2137))) }) {
        Text("->")
    }
}

@Composable
@Destination
fun Second(argument: Argument) {
}

interface Argument : Parcelable

@Parcelize
data class ArgumentImpl(val value: Int) : Argument

When I change the signature of Second function to: fun Second(argument: ArgumentImpl), everything works correctly and there is no exception.

I'm using following versions:

kotlin_version = "1.6.10"

id 'com.google.devtools.ksp' version "$kotlin_version-1.0.2"

final destinations_version = "1.3.1-beta"
implementation "io.github.raamcosta.compose-destinations:core:$destinations_version"
ksp "io.github.raamcosta.compose-destinations:ksp:$destinations_version"

Let me know if you need more information on this issue, I'd be happy to help!

@raamcosta
Copy link
Owner

Hi @pchmielowski !
Thanks for reporting.

Interesting I haven't thought of this before 🤔
I know where is the problem. I will investigate this hopefully today still 🙂

I'll keep you posted.

@raamcosta raamcosta self-assigned this Feb 16, 2022
@raamcosta raamcosta added the bug Something isn't working label Feb 16, 2022
@raamcosta
Copy link
Owner

Fixed and will be available on next release. Maybe I can do a new patch version bump just for this, why not.

@pchmielowski
Copy link
Author

Great news!

@raamcosta
Copy link
Owner

Fix released today with version 1.3.2. Sorry it took me longer than expected, it did not seem to urgent 😅
Hope it was not blocking you!

@pchmielowski
Copy link
Author

It was my personal project and I've temporarily used Serializable instead of Parcelable - but it's a great that now I can upgrade and refactor! Thanks!

raamcosta added a commit that referenced this issue Mar 11, 2022
raamcosta added a commit that referenced this issue Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants