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

Cannot implement OnDestinationChangedListener in multiplatform navigation #4615

Closed
jirkli opened this issue Apr 14, 2024 · 3 comments · Fixed by JetBrains/compose-multiplatform-core#1275
Assignees
Labels
bug Something isn't working navigation

Comments

@jirkli
Copy link

jirkli commented Apr 14, 2024

Describe the bug
When you try to implement NavController.OnDestinationChangedListener, you get an Unresolved reference: Bundle error trying to import the Bundle class from androidx.core.bundle.Bundle.

Affected platforms
Any, since it's in the common implementation.

Versions

  • Kotlin version*: 1.9.22
  • Compose Multiplatform version*: 1.6.10-dev1580
  • JB Androidx navigation version*: 2.8.0-dev1580

To Reproduce

  1. Clone the given Cupcake sample app nav_cupcake
  2. Put anywhere inside the common implementation a class implementing the OnDestinationChangedListener interface. Can be inside the CommonUi file as such:
    class NavListener() : NavController.OnDestinationChangedListener { override fun onDestinationChanged( controller: NavController, destination: NavDestination, arguments: Bundle? ) { TODO("Not yet implemented") } }
  3. Build project
  4. Build fails on unresolved references, even though the imports are present

Expected behavior
Project should be able to be built

@jirkli jirkli added bug Something isn't working submitted labels Apr 14, 2024
@jirkli
Copy link
Author

jirkli commented Apr 16, 2024

For anyone encountering the same error, adding org.jetbrains.androidx.core:core-bundle in version 1.0.0-dev1580 solves this. So maybe just a tooling issue, where Android Studio shows that the import of the Bundle is valid? However, that doesn't explain why exactly the same thing builds without issues in an iOS build without any errors.

@MatkovIvan
Copy link
Member

Thanks for the report - I'll replace implementation to api for this dependency and revisit similar places

@MatkovIvan MatkovIvan reopened this Apr 16, 2024
@MatkovIvan MatkovIvan self-assigned this Apr 16, 2024
MatkovIvan added a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 18, 2024
## Proposed Changes

We have to unwrap all project dependencies, but it seems
`implementation` replaces `api` for other dependencies.

## Testing

Test: try to use `NavController.OnDestinationChangedListener` without
specifying bundle dependency explicitly.

## Issues Fixed

Fixes JetBrains/compose-multiplatform#4615
@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working navigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants