-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Deeplinks and BuildConfig, code not generated #178
Comments
Hi 👋 Thank you for the kind words, glad you like it! I believe this can be due to ksp task running before the build config class is created when you build the app. But I see how good this could be, I’ll leave this open as a future enhancement and I’ll try to check if I can solve it somehow 🤔 In the meantime, one thing you can do is, right before calling DestinationsNavHost, you copy your root NavGraph (since it is a data class) and reach to the Destination you want to add the deep link, then call this (line 112 - withDeepLink). This will create a copy of the generated Destination with the passes in deep link. And this way you can set deep links at runtime. This method was not intended for this specific use case but I believe it should work, but please let me know 🙂 |
Hiya! I have an app with multiple build flavors, and the scheme for the deeplinks is based on the build.FLAVOR. I wrote this code based on your answer. Works for a little bit, until I open a notification with a deeplink. Then it throws the following exception:
|
Hi, you can try adding the code below to your build.gradle, it should make the BuildConfig class available to KSP.
|
I get this build error when using this option:
@cvb941 - Where you able to get it working? If so, mind sharing a few snippets of the code? |
Sorry, I just enabled that option and it worked, nothing special. I am not using kapt though. |
@ryanholden8 Did you find a solution or maybe a workaround? I think my project requires kapt for Hilt, and ksp for destinations. I also need to set ksp. allowSourcesFromOtherPlugins to true because we have build flavors and we need deeplinks based on build flavors. I feel like there must be a way to have ksp_gradleTask.dependsOn(BuildConfig_gradleTask), but I'm not very familiar with ksp and gradle. |
@MiieL - We did not, we duplicated the references. Not ideal but not much of a choice. |
@raamcosta I have many issues with this. Did you solve it? How can I help you to solve it to send Pull Request? |
The way I solved this was to register a single pattern as documented, using an app scheme, for example: Screen @destination annotation
Then, in the MainActivity, I used traditional url- handling to transform environment (prod, dev, acc) specific https urls in to the registered myapp:// pattern and feed that into the navigator MainActivity kotlin:
DeeplinkManager
DeeplinkParser: A class transforming DeeplinkHandler
|
A bit late to the party, but just wanted to share a workaround that worked for me. Might be helpful to some folks out there. I've basically used this suggestion:
but with this extra step:
This little block makes sure that Of course, having an elegant out-of-the-box solution would be way better, but this is not too ugly for a workaround. Hope. this helps! |
@raamcosta is it possible to improve error message in this situation? Error like following is kind of misleading.
|
Does anyone know if this is still the case? |
@raamcosta Is it supposed to be working? Haven't tried since I've put in place the workaround I've mentioned earlier |
It is still the case, facing this |
Hello Rafael,
First of all, I would like to thank you for this great library. A real pleasure to use every day ! 👏
My issue is that I trying to use DeepLinks with a changing configuration, thanks to BuildConfig.
The application compiles, but it crashes when launching on the phone with this error:
java.lang.IllegalStateException: The NavDeepLink must have an uri, action, and/or mimeType.
And indeed, looking in the generated code, nothing appears in the Deeplinks variable.
This works perfectly if I hardcode the URL in the right field, but when I pass it in the BuildConfig, it doesn't generate. And I need it because our application has 4 environments.
Current state :
DashboardScreen.kt
What I try to achieve :
build.gradle
DashboardScreen.kt
Is there a solution ?
Sorry if I missed something in the documentation.
The text was updated successfully, but these errors were encountered: